/* =============================================
   GAO JOIAS — ADMIN DESIGN SYSTEM v2.0
   ============================================= */

:root {
  --bg:             #070a08;
  --bg-soft:        #0b0f0d;
  --surface:        #111712;
  --surface-light:  #172019;
  --surface-bright: #1e2b22;
  --surface-hover:  rgba(255,255,255,0.035);
  --text:           #e8edea;
  --muted:          #7d8f88;
  --subtle:         rgba(255,255,255,0.45);
  --gold:           #c9a84c;
  --gold-light:     #dfc06f;
  --gold-dim:       rgba(201,168,76,0.14);
  --gold-glow:      rgba(201,168,76,0.22);
  --green:          #3ecf8e;
  --green-dim:      rgba(62,207,142,0.14);
  --red:            #f87171;
  --red-dim:        rgba(248,113,113,0.14);
  --blue:           #60a5fa;
  --blue-dim:       rgba(96,165,250,0.14);
  --border:         rgba(255,255,255,0.065);
  --border-md:      rgba(255,255,255,0.10);
  --border-gold:    rgba(201,168,76,0.28);
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.3);
  --shadow:    0 4px 20px rgba(0,0,0,0.4);
  --shadow-lg: 0 20px 60px rgba(0,0,0,0.55);
  --shadow-xl: 0 40px 100px rgba(0,0,0,0.65);
  --r-xs:   6px;
  --r-sm:   10px;
  --r-md:   14px;
  --r-lg:   18px;
  --r-xl:   24px;
  --r-full: 9999px;
  --radius-lg: var(--r-xl);
  --radius-md: var(--r-md);
  --radius-sm: var(--r-sm);
  --ease:           cubic-bezier(0.4, 0, 0.2, 1);
  --transition:     0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-md:  0.28s cubic-bezier(0.4, 0, 0.2, 1);
  --sidebar-transition: 0.38s cubic-bezier(0.4, 0, 0.2, 1);
  --sidebar-width:           264px;
  --sidebar-collapsed-width: 72px;
  --footer-height:           42px;
}

[data-theme='light'] {
  --bg:            #f0ede6;
  --bg-soft:       #e6e2db;
  --surface:       #ffffff;
  --surface-light: #f7f5f0;
  --surface-bright:#eeebe4;
  --surface-hover: rgba(0,0,0,0.025);
  --text:          #1a1d1b;
  --muted:         #6b7472;
  --subtle:        rgba(0,0,0,0.38);
  --gold:          #a87824;
  --gold-light:    #c99332;
  --gold-dim:      rgba(168,120,36,0.1);
  --gold-glow:     rgba(168,120,36,0.18);
  --green:         #18a46a;
  --green-dim:     rgba(24,164,106,0.12);
  --red:           #dc4e4e;
  --red-dim:       rgba(220,78,78,0.1);
  --blue:          #3b7fe8;
  --blue-dim:      rgba(59,127,232,0.12);
  --border:        rgba(0,0,0,0.08);
  --border-md:     rgba(0,0,0,0.12);
  --border-gold:   rgba(168,120,36,0.28);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow:    0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.12);
  --shadow-xl: 0 32px 80px rgba(0,0,0,0.16);
}

/* ---- RESET ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; max-width: 100%; overflow-x: hidden; }

body {
  font-family: 'Inter', 'Poppins', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv02','cv03','cv04','cv11';
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% 0%, rgba(201,168,76,0.06) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(62,207,142,0.04) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

[data-theme='light'] body::before {
  background:
    radial-gradient(ellipse 80% 50% at 15% 0%, rgba(168,120,36,0.07) 0%, transparent 55%),
    radial-gradient(ellipse 60% 40% at 85% 100%, rgba(24,164,106,0.04) 0%, transparent 55%);
}

.hidden { display: none !important; }

/* ---- BACKGROUND DECORATIONS ---- */
.bg-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  pointer-events: none;
  z-index: 0;
}
.bg-orb--one {
  width: 520px; height: 520px;
  top: -200px; left: -160px;
  background: radial-gradient(circle, rgba(201,168,76,0.11), transparent 70%);
}
.bg-orb--two {
  width: 420px; height: 420px;
  bottom: -160px; right: -130px;
  background: radial-gradient(circle, rgba(62,207,142,0.07), transparent 70%);
}
.bg-grid {
  position: fixed; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.017) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.017) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
  z-index: 0;
}
[data-theme='light'] .bg-grid {
  background-image:
    linear-gradient(rgba(0,0,0,0.026) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,0,0,0.026) 1px, transparent 1px);
}

/* ---- TOAST ---- */
.toast {
  position: fixed;
  top: 18px; right: 18px;
  max-width: 360px;
  padding: 13px 17px;
  background: var(--surface-bright);
  border: 1px solid var(--border-md);
  border-left: 3px solid var(--gold);
  color: var(--text);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateX(calc(100% + 20px));
  transition: opacity 0.26s var(--ease), transform 0.32s cubic-bezier(0.34,1.56,0.64,1);
  z-index: 300;
  pointer-events: none;
  visibility: hidden;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.45;
  backdrop-filter: blur(20px);
}
.toast.show {
  opacity: 1;
  transform: translateX(0);
  visibility: visible;
}
[data-theme='light'] .toast {
  background: #fff;
  border-color: rgba(0,0,0,0.08);
  border-left-color: var(--gold);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}

/* ---- LOADING OVERLAY ---- */
.loading {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  display: grid; place-items: center;
  z-index: 280;
  backdrop-filter: blur(6px);
}
[data-theme='light'] .loading { background: rgba(255,255,255,0.6); }

.loading-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border-gold);
  padding: 16px 22px;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xl);
  backdrop-filter: blur(24px);
}
.loading-card strong { font-size: 14px; font-weight: 600; }
.loading-card small  { color: var(--muted); font-size: 12px; display: block; }
[data-theme='light'] .loading-card { background: #fff; border-color: rgba(0,0,0,0.1); }

.spinner {
  flex-shrink: 0;
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 2.5px solid var(--gold-dim);
  border-top-color: var(--gold);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- LOGIN ---- */
.login {
  position: relative; z-index: 2;
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 40px 20px calc(40px + var(--footer-height));
}

.login-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border-gold);
  border-radius: var(--r-xl);
  padding: 36px 32px;
  box-shadow: var(--shadow-xl);
  backdrop-filter: blur(24px);
  position: relative;
  overflow: hidden;
}
.login-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-light), transparent);
  opacity: 0.5;
}
[data-theme='light'] .login-card {
  background: #fff;
  border-color: rgba(168,120,36,0.25);
  box-shadow: var(--shadow-lg);
}

.brand {
  display: flex; gap: 14px; align-items: center;
  margin-bottom: 28px;
}
.brand img {
  width: 48px; height: 48px;
  border-radius: var(--r-sm);
  background: var(--gold-dim);
  padding: 8px;
  border: 1px solid var(--border-gold);
}
.brand h1 { font-size: 20px; font-weight: 700; letter-spacing: -0.3px; }
.brand p  { color: var(--muted); font-size: 12.5px; margin-top: 1px; }

.login-form    { display: grid; gap: 14px; }
.login-profiles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.profile-select {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 7px; min-height: 40px; padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-light);
  color: var(--muted);
  font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
.profile-select:hover        { border-color: var(--border-gold); color: var(--text); background: var(--gold-dim); }
.profile-select.active       { border-color: var(--gold); background: var(--gold-dim); color: var(--text); }
[data-theme='light'] .profile-select { background: rgba(0,0,0,0.04); border-color: rgba(0,0,0,0.1); }
[data-theme='light'] .profile-select:hover,
[data-theme='light'] .profile-select.active { background: rgba(168,120,36,0.1); border-color: rgba(168,120,36,0.3); }

.login-footer {
  margin-top: 12px;
  color: var(--muted); font-size: 12px; text-align: center;
}

/* ---- FORM ELEMENTS ---- */
label {
  display: grid; gap: 5px;
  font-size: 12.5px; font-weight: 500;
  color: var(--muted); letter-spacing: 0.01em;
}
label span {
  display: inline-flex; align-items: center; gap: 7px;
  color: var(--text);
}

input, select {
  width: 100%;
  padding: 10px 13px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-md);
  background: var(--surface-light);
  color: var(--text);
  font: inherit; font-size: 13.5px;
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
  appearance: none;
}
select {
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23c9a84c' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  cursor: pointer;
}
[data-theme='light'] select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23a87824' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
[data-theme='light'] input,
[data-theme='light'] select {
  background-color: #fff;
  border-color: rgba(0,0,0,0.14);
  color: var(--text);
}
input:focus, select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-dim);
}
input[type='checkbox'] {
  width: auto; min-width: 16px; height: 16px;
  border-radius: 4px; accent-color: var(--gold);
  cursor: pointer; padding: 0;
}
input::placeholder { color: var(--muted); opacity: 0.7; }

.password-field { position: relative; }
.password-field input { padding-right: 44px; }
.password-toggle {
  position: absolute; top: 50%; right: 6px;
  transform: translateY(-50%);
  width: 32px; height: 32px;
  border-radius: var(--r-xs);
  border: none; background: transparent;
  color: var(--muted); cursor: pointer;
  display: grid; place-items: center;
  transition: var(--transition);
}
.password-toggle:hover { color: var(--text); background: var(--surface-hover); }

/* ---- BUTTONS ---- */
.btn {
  border: none; border-radius: var(--r-full);
  padding: 10px 18px;
  font: inherit; font-size: 13.5px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 7px;
  cursor: pointer; transition: var(--transition-md);
  white-space: nowrap; max-width: 100%;
}
.btn i { font-size: 0.9em; }

.btn-primary {
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-light) 100%);
  color: #0a0c0b;
  justify-content: center;
  position: relative; overflow: hidden;
}
.btn-primary::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, transparent, rgba(255,255,255,0.15));
  opacity: 0; transition: var(--transition);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px var(--gold-glow);
}
.btn-primary:hover::after { opacity: 1; }
.btn-primary:active       { transform: translateY(0); box-shadow: none; }

.btn-ghost {
  background: var(--surface-light);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-bright); border-color: var(--border-md); }
[data-theme='light'] .btn-ghost { background: rgba(0,0,0,0.04); border-color: rgba(0,0,0,0.1); }
[data-theme='light'] .btn-ghost:hover { background: rgba(0,0,0,0.07); border-color: rgba(0,0,0,0.15); }

.icon-btn {
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface-light);
  color: var(--text);
  display: grid; place-items: center;
  cursor: pointer; font-size: 13px;
  transition: var(--transition);
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface-bright); border-color: var(--border-md); }
.icon-btn--sm { width: 30px; height: 30px; border-radius: var(--r-xs); font-size: 12px; }
[data-theme='light'] .icon-btn { background: rgba(0,0,0,0.04); border-color: rgba(0,0,0,0.1); }
[data-theme='light'] .icon-btn:hover { background: rgba(0,0,0,0.07); }

/* ---- GLOBAL FOOTER ---- */
.global-footer {
  position: fixed; left: 50%;
  bottom: calc(12px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 160;
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--muted); font-size: 11.5px; font-weight: 500;
  white-space: nowrap; pointer-events: auto;
}
.global-footer a { color: var(--text); text-decoration: none; font-weight: 700; }
.global-footer a:hover { color: var(--gold); }

/* ---- APP SHELL ---- */
.app { position: relative; z-index: 2; min-height: 100vh; width: 100%; max-width: 100%; }

/* ---- SIDEBAR ---- */
.sidebar {
  width: var(--sidebar-width);
  height: 100dvh;
  position: fixed; inset: 0 auto 0 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 12px;
  display: flex; flex-direction: column; gap: 4px;
  transition: width var(--sidebar-transition);
  overflow-y: auto; overflow-x: hidden;
  z-index: 90;
  scrollbar-width: thin;
  scrollbar-color: var(--border-md) transparent;
}
.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-md); border-radius: 2px; }
[data-theme='light'] .sidebar {
  background: #fff;
  border-right-color: rgba(0,0,0,0.08);
  box-shadow: 2px 0 16px rgba(0,0,0,0.04);
}

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 6px 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.sidebar-brand .icon-btn { margin-left: auto; flex-shrink: 0; }
.sidebar-brand img {
  width: 38px; height: 38px;
  border-radius: var(--r-xs);
  background: transparent;
  padding: 1px;
  border: none;
  flex-shrink: 0;
}
.sidebar-brand strong { font-size: 15px; font-weight: 700; letter-spacing: -0.3px; }
.sidebar-brand small  { color: var(--muted); font-size: 11px; display: block; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.nav-link {
  width: 100%; background: transparent; color: var(--muted);
  border: none; border-radius: var(--r-sm);
  padding: 9px 10px;
  display: flex; align-items: center; gap: 10px;
  cursor: pointer; transition: var(--transition);
  font: inherit; font-size: 13.5px; font-weight: 500;
  position: relative; text-align: left;
  white-space: nowrap; overflow: hidden;
}
.nav-link i {
  font-size: 14px; width: 18px; text-align: center;
  flex-shrink: 0; transition: color var(--transition);
}
.nav-link:hover { background: var(--surface-hover); color: var(--text); }
[data-theme='light'] .nav-link:hover { background: rgba(0,0,0,0.04); }

.nav-link.active {
  background: var(--gold-dim);
  color: var(--text); font-weight: 600;
}
.nav-link.active i { color: var(--gold); }
.nav-link.active::before {
  content: '';
  position: absolute; left: 0; top: 6px; bottom: 6px;
  width: 3px; border-radius: 0 2px 2px 0;
  background: var(--gold);
}
[data-theme='light'] .nav-link.active {
  background: rgba(168,120,36,0.1);
}
[data-theme='light'] .nav-link.active i { color: var(--gold); }
[data-theme='light'] .nav-link.active::before { background: var(--gold); }

.sidebar-footer {
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: grid; gap: 10px;
  margin-top: auto;
}

.profile {
  display: flex; gap: 10px; align-items: center;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  background: var(--surface-light);
  border: 1px solid var(--border);
}
.profile span, .nav-link span, .btn span { display: inline-block; }

.avatar {
  width: 34px; height: 34px;
  border-radius: var(--r-xs);
  background: var(--gold-dim); color: var(--gold);
  display: grid; place-items: center;
  font-weight: 700; font-size: 13px;
  border: 1px solid var(--border-gold);
  flex-shrink: 0; letter-spacing: 0.5px;
}
.profile strong { font-size: 13px; font-weight: 600; display: block; line-height: 1.3; }
.profile small  { color: var(--muted); font-size: 11px; display: block; }
[data-theme='light'] .profile { background: rgba(0,0,0,0.03); border-color: rgba(0,0,0,0.08); }
[data-theme='light'] .avatar  { background: rgba(168,120,36,0.1); border-color: rgba(168,120,36,0.25); }

/* ---- COLLAPSED SIDEBAR ---- */
.app.collapsed .sidebar { width: var(--sidebar-collapsed-width); padding: 16px 8px; }
.app.collapsed .content { margin-left: var(--sidebar-collapsed-width); }
.app.collapsed .sidebar-brand { padding: 4px 4px 16px; justify-content: center; }
.app.collapsed .sidebar-brand div,
.app.collapsed .profile div,
.app.collapsed .nav-link span,
.app.collapsed .btn span { display: none; }
.app.collapsed .sidebar-brand img  { margin: 0 auto; }
.app.collapsed .sidebar-brand .icon-btn { margin-left: 0; display: none; }
.app.collapsed .nav-link { justify-content: center; padding: 10px; }
.app.collapsed .nav-link i { width: auto; }
.app.collapsed .nav-link.active::before { top: 5px; bottom: 5px; }
.app.collapsed .profile { justify-content: center; background: var(--gold-dim); border-color: var(--border-gold); padding: 8px; }
.app.collapsed #logout-btn { justify-content: center; padding: 10px; border-radius: var(--r-sm); }

/* ---- CONTENT ---- */
.content {
  margin-left: var(--sidebar-width);
  padding: 24px 28px calc(40px + var(--footer-height));
  min-width: 0; min-height: 100vh;
  transition: margin-left var(--sidebar-transition);
}

/* ---- TOPBAR ---- */
.topbar {
  display: flex; align-items: center;
  justify-content: space-between;
  gap: 12px; margin-bottom: 24px; min-width: 0;
}
.topbar-title { min-width: 0; }
.topbar-title h2 {
  font-size: 22px; font-weight: 700;
  letter-spacing: -0.4px; line-height: 1.2;
}
.topbar-title p { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.topbar-actions > * { min-width: 0; }

.chip {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 6px 12px; border-radius: var(--r-full);
  background: var(--green-dim); color: var(--green);
  font-size: 11.5px; font-weight: 600;
  border: 1px solid rgba(62,207,142,0.2);
  white-space: nowrap;
}
[data-theme='light'] .chip {
  background: rgba(24,164,106,0.1);
  color: var(--green);
  border-color: rgba(24,164,106,0.2);
}

/* ---- VIEWS ---- */
.view {
  display: none; flex-direction: column;
  gap: 20px; min-width: 0;
  animation: fadeUp 0.22s cubic-bezier(0.4,0,0.2,1) both;
}
.view.active { display: flex; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- PANELS ---- */
.panel {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 20px 22px;
  border: 1px solid var(--border);
  min-width: 0; position: relative;
}
[data-theme='light'] .panel {
  background: #fff;
  border-color: rgba(0,0,0,0.08);
  box-shadow: var(--shadow-sm);
}
.panel canvas { width: 100% !important; height: 240px !important; }

.panel-header {
  display: flex; align-items: center;
  justify-content: space-between;
  gap: 12px; margin-bottom: 18px;
  min-width: 0; flex-wrap: wrap;
}
.panel-header > * { min-width: 0; }
.panel-header h4 {
  font-size: 15px; font-weight: 700;
  letter-spacing: -0.2px;
}
.panel-header .search-input { flex: 1; min-width: 0; }
.panel-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---- STATS GRID ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  border: 1px solid var(--border);
  display: grid; gap: 4px;
  position: relative; overflow: hidden;
  transition: border-color var(--transition), transform var(--transition);
}
.stat-card:hover { transform: translateY(-1px); border-color: var(--border-md); }
[data-theme='light'] .stat-card { background: #fff; box-shadow: var(--shadow-sm); }

.stat-card.highlight {
  border-color: var(--border-gold);
  background: linear-gradient(135deg, var(--surface) 60%, var(--gold-dim));
}
.stat-card.highlight::after {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--gold), var(--gold-light), var(--gold));
  border-radius: var(--r-xl) var(--r-xl) 0 0;
}
[data-theme='light'] .stat-card.highlight { border-color: rgba(168,120,36,0.3); }

.pulse-card { animation: pulseGlow 2.5s ease-in-out infinite; }
@keyframes pulseGlow {
  0%,100% { box-shadow: 0 0 0 0 rgba(201,168,76,0.1); }
  50%      { box-shadow: 0 0 0 6px rgba(201,168,76,0.04), var(--shadow); }
}
[data-theme='light'] .pulse-card { animation-name: pulseGlowLight; }
@keyframes pulseGlowLight {
  0%,100% { box-shadow: 0 0 0 0 rgba(168,120,36,0.08), var(--shadow-sm); }
  50%      { box-shadow: 0 0 0 6px rgba(168,120,36,0.03), var(--shadow); }
}
@media (prefers-reduced-motion: reduce) {
  .pulse-card { animation: none; }
  .view       { animation: none; }
}

.stat-card p { color: var(--muted); font-size: 12px; font-weight: 500; }
.stat-card h3 {
  font-size: 26px; font-weight: 700;
  letter-spacing: -0.5px; line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.stat-card span { color: var(--muted); font-size: 11.5px; font-weight: 500; }

/* ---- PERIOD SWITCH ---- */
.period-switch {
  display: flex; flex-wrap: wrap; gap: 4px;
  background: var(--surface-light);
  padding: 4px; border-radius: var(--r-full);
  border: 1px solid var(--border);
  width: fit-content;
}
.period-btn {
  border: none; background: transparent;
  color: var(--muted); border-radius: var(--r-full);
  padding: 5px 13px;
  font: inherit; font-size: 12.5px; font-weight: 600;
  cursor: pointer; transition: var(--transition);
}
.period-btn:hover { color: var(--text); background: var(--surface-hover); }
.period-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}
[data-theme='light'] .period-switch { background: rgba(0,0,0,0.04); border-color: rgba(0,0,0,0.1); }
[data-theme='light'] .period-btn.active { background: #fff; border-color: rgba(0,0,0,0.1); }

.metric-up   { color: var(--green) !important; }
.metric-down { color: var(--red)   !important; }
.metric-flat { color: var(--muted) !important; }

/* ---- LAYOUTS ---- */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }

/* ---- SEARCH ---- */
.search-input { position: relative; min-width: 0; }
.search-input i {
  position: absolute; left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--muted); font-size: 12px; pointer-events: none;
}
.search-input .input { padding-left: 34px; }

/* ---- INPUT UTILITY ---- */
.input {
  width: 100% !important;
  padding: 9px 14px;
  border-radius: var(--r-full) !important;
  border: 1px solid var(--border-md);
  background: var(--surface-light);
  color: var(--text);
  font: inherit; font-size: 13px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-dim); }
[data-theme='light'] .input { background: #fff; border-color: rgba(0,0,0,0.12); }
[data-theme='light'] .input:focus { box-shadow: 0 0 0 3px rgba(168,120,36,0.12); }

/* ---- FORM GRID ---- */
.form-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  min-width: 0;
}
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---- BUILDER CARDS ---- */
.builder-card {
  display: grid; gap: 14px;
  padding: 18px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--bg-soft);
  min-width: 0;
}
[data-theme='light'] .builder-card {
  background: var(--surface-light);
  border-color: rgba(0,0,0,0.08);
}
.builder-head {
  display: flex; align-items: flex-start;
  justify-content: space-between; gap: 12px;
}
.builder-head h5 { font-size: 14px; font-weight: 700; margin-bottom: 3px; }
.builder-head-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.builder-list { display: grid; gap: 10px; }

.builder-row {
  display: grid;
  grid-template-columns: 110px minmax(220px, 1.25fr) minmax(240px, 1.45fr) 90px 130px 130px auto;
  gap: 10px; padding: 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  align-items: end;
}
.payment-row {
  grid-template-columns: minmax(220px, 1.7fr) 120px 120px 120px 150px 150px auto;
}
[data-theme='light'] .builder-row { background: #fff; border-color: rgba(0,0,0,0.08); }

.builder-row label  { min-width: 0; gap: 6px; }
.builder-row input,
.builder-row select { min-width: 0; }
.builder-remove-btn { align-self: center; }

.form-callout {
  display: grid; gap: 3px;
  padding: 12px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-gold);
  background: linear-gradient(135deg, var(--gold-dim), var(--green-dim));
}
.form-callout strong { font-size: 14px; font-weight: 700; }

/* ---- BUILDER SUMMARY ---- */
.builder-summary { display: flex; flex-wrap: wrap; gap: 8px; }
.summary-chip {
  min-width: 130px; padding: 10px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-gold);
  background: var(--gold-dim);
  display: grid; gap: 3px;
}
.summary-chip span {
  font-size: 10.5px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600;
}
.summary-chip strong {
  font-size: 14px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
[data-theme='light'] .summary-chip {
  background: rgba(168,120,36,0.08);
  border-color: rgba(168,120,36,0.22);
}

/* ---- TABLES ---- */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface);
}
[data-theme='light'] .table-wrapper {
  border-color: rgba(0,0,0,0.08);
  background: #fff;
}
.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}
.table thead {
  background: var(--surface-light);
  position: sticky; top: 0; z-index: 1;
}
[data-theme='light'] .table thead { background: var(--surface-light); }

.table th {
  padding: 11px 14px;
  text-align: left;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 12px 14px;
  text-align: left; font-size: 13px;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover { background: var(--surface-hover); }
[data-theme='light'] .table tbody tr:hover { background: rgba(0,0,0,0.025); }

@media (max-width: 860px) {
  .table { min-width: 0; }
  .table thead { display: none; }
  .table-wrapper { border: none; border-radius: 0; background: transparent; }
  .table tbody tr {
    display: block; margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 8px 10px;
    background: var(--surface);
  }
  .table tbody tr:hover { background: var(--surface-light); }
  .table td {
    display: flex; align-items: flex-start;
    justify-content: space-between; gap: 12px;
    padding: 8px 6px;
    border-bottom: 1px dashed var(--border);
  }
  .table td::before {
    content: attr(data-label);
    color: var(--muted); font-size: 10.5px;
    text-transform: uppercase; letter-spacing: 0.05em;
    font-weight: 700; max-width: 45%; flex-shrink: 0;
  }
  .table td > * { max-width: 55%; text-align: right; word-break: break-word; }
  .table td:last-child { border-bottom: none; }
  .table td[data-label='Acoes'] { justify-content: flex-start; }
  .table td[data-label='Acoes'] > * { max-width: 100%; }
  .actions { gap: 6px; flex-wrap: wrap; }
}

/* ---- BADGES ---- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: var(--r-full);
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.02em; white-space: nowrap;
}
.badge.success { background: var(--green-dim); color: var(--green); border: 1px solid rgba(62,207,142,0.2); }
.badge.warn    { background: var(--gold-dim);  color: var(--gold);  border: 1px solid var(--border-gold); }
.badge.danger  { background: var(--red-dim);   color: var(--red);   border: 1px solid rgba(248,113,113,0.2); }
.badge.info    { background: var(--blue-dim);  color: var(--blue);  border: 1px solid rgba(96,165,250,0.2); }
.badge.neutral { background: rgba(150,160,155,0.1); color: var(--muted); border: 1px solid var(--border); }

/* ---- LIST ---- */
.list { display: grid; gap: 6px; }
.list-item {
  padding: 11px 14px;
  border-radius: var(--r-sm);
  background: var(--surface-light);
  border: 1px solid var(--border);
  display: flex; justify-content: space-between;
  align-items: center; gap: 10px;
  font-size: 13px; transition: background var(--transition);
}
.list-item:hover { background: var(--surface-bright); }
.list-item strong { font-weight: 600; font-variant-numeric: tabular-nums; }
[data-theme='light'] .list-item { background: rgba(0,0,0,0.025); border-color: rgba(0,0,0,0.07); }
[data-theme='light'] .list-item:hover { background: rgba(0,0,0,0.045); }

/* ---- CONFIG ---- */
.config-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.config-card {
  background: var(--surface-light);
  border-radius: var(--r-md);
  padding: 20px;
  border: 1px solid var(--border);
  display: grid; gap: 12px;
}
[data-theme='light'] .config-card { background: #fff; border-color: rgba(0,0,0,0.08); box-shadow: var(--shadow-sm); }
.config-card h5 { font-size: 13.5px; font-weight: 700; }
.config-card p  { color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.config-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.compact-label  { max-width: 220px; }

#thermal-status {
  min-height: 38px; padding: 9px 12px;
  border-radius: var(--r-sm);
  background: var(--surface); color: var(--muted);
  font-size: 12.5px; line-height: 1.4;
  border: 1px solid var(--border);
}
#thermal-status[data-status='ok'] {
  color: var(--green); background: var(--green-dim);
  border-color: rgba(62,207,142,0.2);
}
[data-theme='light'] #thermal-status { background: rgba(0,0,0,0.03); border-color: rgba(0,0,0,0.1); }
[data-theme='light'] #thermal-status[data-status='ok'] {
  background: rgba(24,164,106,0.08); border-color: rgba(24,164,106,0.2);
}

/* ---- ACTIONS ---- */
.actions { display: flex; flex-wrap: wrap; gap: 5px; }
.action-btn {
  padding: 5px 11px; font-size: 12px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--surface-light); color: var(--muted);
  cursor: pointer; font: inherit; font-size: 12px; font-weight: 600;
  transition: var(--transition);
  display: inline-flex; align-items: center; gap: 5px;
  white-space: nowrap;
}
.action-btn:hover { color: var(--text); background: var(--surface-bright); border-color: var(--border-md); }
[data-theme='light'] .action-btn { background: rgba(0,0,0,0.04); border-color: rgba(0,0,0,0.1); }
[data-theme='light'] .action-btn:hover { background: rgba(0,0,0,0.07); border-color: rgba(0,0,0,0.15); color: var(--text); }

.action-btn[data-action='whatsapp']:hover { background: rgba(37,211,102,0.14); border-color: rgba(37,211,102,0.3); color: #25d366; }
.action-btn[data-action='confirm']:hover,
.action-btn[data-action='like']:hover     { background: var(--green-dim); border-color: rgba(62,207,142,0.3); color: var(--green); }
.action-btn[data-action='reject']:hover   { background: var(--red-dim);   border-color: rgba(248,113,113,0.3); color: var(--red); }
.action-btn[data-action='pdf']:hover      { background: var(--gold-dim);  border-color: var(--border-gold); color: var(--gold); }
.action-btn[data-action='print']:hover,
.action-btn[data-action='nota']:hover,
.action-btn[data-action='view']:hover     { background: var(--surface-bright); border-color: var(--border-md); color: var(--text); }

/* ---- MODAL ACTIONS ---- */
.modal-actions {
  display: flex; align-items: center;
  justify-content: space-between; gap: 16px;
  margin-bottom: 16px; position: relative;
}
.modal-actions .icon-btn {
  position: absolute; top: -16px; right: -16px;
  background: var(--surface); border: 1px solid var(--border-md);
  box-shadow: var(--shadow);
}
.modal-actions .icon-btn:hover {
  background: var(--red-dim);
  border-color: rgba(248,113,113,0.3); color: var(--red);
}
[data-theme='light'] .modal-actions .icon-btn { background: #fff; border-color: rgba(0,0,0,0.12); color: var(--text); }
[data-theme='light'] .modal-actions .icon-btn:hover {
  background: rgba(220,78,78,0.1);
  border-color: rgba(220,78,78,0.3); color: var(--red);
}
[data-theme='light'] .modal-actions .btn-ghost {
  background: rgba(0,0,0,0.04); color: var(--text);
}
[data-theme='light'] .modal-actions .btn-ghost:hover {
  background: rgba(0,0,0,0.07);
}

/* ---- DOCUMENT (PDF/PRINT) ---- */
.doc {
  background: #fff; color: #1b1b1b;
  border-radius: 16px; padding: 28px;
  border: 1px solid #ededed;
  box-shadow: 0 16px 40px rgba(0,0,0,0.08);
  width: 100%;
}
.doc-header {
  display: flex; align-items: center;
  justify-content: space-between; gap: 20px;
  border-bottom: 1px solid #eaeaea; padding-bottom: 16px;
}
.doc-header .brand-block { display: flex; align-items: center; gap: 12px; }
.doc-header img { width: 56px; height: 56px; object-fit: contain; }
.doc-title {
  text-transform: uppercase; letter-spacing: 1.5px;
  font-size: 10px; color: #888; font-weight: 700;
}
.doc-number { font-size: 22px; font-weight: 800; letter-spacing: -0.3px; }
.doc-meta {
  margin-top: 16px; display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px;
}
.doc-meta div { background: #f7f7f7; border: 1px solid #efefef; border-radius: 8px; padding: 9px 12px; }
.doc-meta span { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: #888; font-weight: 700; }
.doc-meta strong { font-size: 13.5px; font-weight: 600; }
.doc-section { margin-top: 18px; display: grid; gap: 8px; }
.doc h4 { font-size: 14px; font-weight: 700; margin: 0; }
.doc p  { margin: 0; }
.doc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.doc-table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.doc-table th {
  text-align: left; font-size: 10.5px;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: #777; border-bottom: 1px solid #ddd;
  padding: 8px 6px; font-weight: 700;
}
.doc-table td { padding: 10px 6px; border-bottom: 1px dashed #e5e5e5; font-size: 13px; }
.doc-table th:last-child, .doc-table td:last-child { text-align: right; }
.doc-total { margin-top: 16px; display: flex; justify-content: flex-end; }
.doc-total .total-box {
  background: #111; color: #fff;
  border-radius: 10px; padding: 12px 16px;
  min-width: 180px; text-align: right;
}
.doc-total .total-box span {
  display: block; font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.08em;
  opacity: 0.7; font-weight: 700;
}
.doc-total .total-box strong { font-size: 20px; font-weight: 800; }
.doc-footer { margin-top: 16px; font-size: 12px; color: #666; }
.doc.thermal { padding: 16px; border-radius: 0; box-shadow: none; }
.doc.thermal .doc-meta { grid-template-columns: 1fr; }
.doc.thermal .doc-table th,
.doc.thermal .doc-table td { font-size: 11px; }

/* ---- DRAWER / MODAL ---- */
.drawer, .modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: grid; place-items: center;
  z-index: 120;
  backdrop-filter: blur(8px);
}
[data-theme='light'] .drawer,
[data-theme='light'] .modal { background: rgba(0,0,0,0.32); }

.drawer-content {
  width: min(680px, 94vw);
  background: var(--surface);
  border-radius: var(--r-xl); padding: 26px;
  border: 1px solid var(--border-md);
  position: relative;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: modalIn 0.26s cubic-bezier(0.4,0,0.2,1) both;
}
[data-theme='light'] .drawer-content { background: #fff; border-color: rgba(0,0,0,0.1); }

.drawer-content .icon-btn { position: absolute; top: 18px; right: 18px; }
.drawer-content[data-variant='wide-form'] { width: min(1180px, 96vw); }
.drawer-content h3 { margin: 0 52px 12px 0; font-size: 22px; font-weight: 700; letter-spacing: -0.4px; }
.drawer-content[data-variant='wide-form'] .form-grid { gap: 16px; }
.drawer-content[data-variant='wide-form'] .builder-card { padding: 20px; }
.drawer-content[data-variant='wide-form'] .builder-row { gap: 12px; padding: 14px; }

.modal-content {
  width: min(820px, 94vw);
  background: var(--bg-soft);
  border-radius: var(--r-xl); padding: 28px;
  border: 1px solid var(--border-md);
  box-shadow: var(--shadow-xl);
  max-height: 90vh; overflow-y: auto;
  animation: modalIn 0.26s cubic-bezier(0.4,0,0.2,1) both;
}
[data-theme='light'] .modal-content { background: #f8f8f6; border-color: rgba(0,0,0,0.1); color: var(--text); }

@keyframes modalIn {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

/* ---- UTILITY ---- */
.muted { color: var(--muted); font-size: 12px; }

/* ---- RESPONSIVE ---- */
@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(82vw, 300px);
    max-width: calc(100vw - 48px);
    transform: translateX(-105%);
    transition: transform var(--transition-md), width var(--sidebar-transition);
    box-shadow: var(--shadow-xl);
  }
  .app.collapsed { grid-template-columns: 1fr; }
  .app.collapsed .sidebar-brand div,
  .app.collapsed .profile div,
  .app.collapsed .nav-link span,
  .app.collapsed .btn span { display: inline-block; }
  .sidebar.open { transform: translateX(0); }
  .content { margin-left: 0; padding: 18px 18px calc(18px + var(--footer-height)); }
  .app.collapsed .content { margin-left: 0; }

  .topbar { display: grid; grid-template-columns: auto minmax(0,1fr); align-items: center; gap: 10px; }
  .topbar-title { grid-column: 2; grid-row: 1; }
  .topbar-actions {
    grid-column: 1 / -1;
    display: grid; grid-template-columns: repeat(2, minmax(0,1fr));
    gap: 8px; width: 100%;
  }
  .topbar-actions .chip { grid-column: 1 / -1; }
  .topbar-actions .btn, .topbar-actions .chip { width: 100%; justify-content: center; }
  .topbar-actions .btn span, .topbar-actions .chip { white-space: normal; word-break: break-word; }
  .panel-header { flex-direction: column; align-items: stretch; }
  .period-switch { width: 100%; border-radius: var(--r-sm); }
  .period-btn { flex: 1; text-align: center; border-radius: var(--r-sm); }
  .panel-actions { width: 100%; }
  .search-input { width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid label { min-width: 0; }
  .form-grid .full { grid-column: 1 / -1; }
  .form-grid .btn { width: 100%; justify-content: center; }
  .builder-head { flex-direction: column; align-items: stretch; }
  .builder-head-actions { justify-content: stretch; }
  .builder-head > .btn, .builder-head-actions .btn { width: 100%; justify-content: center; }
  .builder-row, .payment-row { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .builder-remove-btn { width: 100%; justify-self: stretch; }
}

@media (max-width: 720px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .table { min-width: 0; }
  .content { padding: 14px 14px calc(14px + var(--footer-height) + env(safe-area-inset-bottom)); }
  .panel { padding: 16px; }
  .panel-header h4 { font-size: 14.5px; }
  .form-grid { gap: 10px; }
  .table tbody tr { padding: 6px 8px; }
  .topbar-actions { grid-template-columns: 1fr; }
  .topbar-title h2 { font-size: 20px; }
  .period-btn { flex: 1 1 100%; }
  .builder-card { padding: 14px; }
  .builder-row, .payment-row { grid-template-columns: 1fr; padding: 12px; }
  .summary-chip { width: 100%; min-width: 0; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .sidebar { width: min(88vw, 300px); max-width: calc(100vw - 28px); }
}

/* =============================================
   SIDEBAR TAB (fichário toggle) + menu-btn
   ============================================= */
#menu-btn { display: none; }

@media (max-width: 980px) {
  #menu-btn { display: inline-flex; }
}

#sidebar-tab {
  position: fixed;
  top: 5.5%;
  left: var(--sidebar-width);
  transform: translateX(-1px);
  z-index: 95;
  width: 20px;
  height: 64px;
  padding: 0;
  background: var(--surface);
  border: none;
  border-radius: 0 14px 14px 0;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  box-shadow: 4px 0 16px rgba(0,0,0,0.35);
  transition:
    left var(--sidebar-transition),
    width var(--transition),
    background var(--transition),
    color var(--transition),
    box-shadow var(--transition);
}

#sidebar-tab:hover {
  width: 26px;
  background: var(--surface-bright);
  color: var(--gold);
  box-shadow: 5px 0 22px rgba(0,0,0,0.45);
}

.sidebar-tab-icon {
  transition: transform var(--sidebar-transition);
  line-height: 1;
}

.app.collapsed #sidebar-tab {
  left: var(--sidebar-collapsed-width);
}

.app.collapsed .sidebar-tab-icon {
  transform: rotate(180deg);
}

[data-theme='light'] #sidebar-tab {
  background: var(--surface);
  box-shadow: 4px 0 12px rgba(0,0,0,0.09);
  color: var(--muted);
}

[data-theme='light'] #sidebar-tab:hover {
  background: var(--surface-bright);
  color: var(--gold);
  box-shadow: 5px 0 16px rgba(0,0,0,0.12);
}

@media (max-width: 980px) {
  #sidebar-tab { display: none; }
}

/* =============================================
   SMART MODAL (form creation overlay)
   ============================================= */
.smart-modal {
  position: fixed;
  inset: 0;
  z-index: 140;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  visibility: hidden;
  pointer-events: none;
}

.smart-modal.open {
  visibility: visible;
  pointer-events: auto;
}

.smart-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.58);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}

.smart-modal.open .smart-modal-backdrop {
  opacity: 1;
}

.smart-modal-dialog {
  position: relative;
  z-index: 1;
  width: min(600px, 100%);
  max-height: 92vh;
  background: var(--surface);
  border-radius: var(--r-xl);
  border: 1px solid var(--border-gold);
  box-shadow: var(--shadow-xl), 0 0 0 1px rgba(201,168,76,0.06);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: scale(0.94) translateY(18px);
  transition:
    opacity 0.32s var(--ease),
    transform 0.36s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.smart-modal.open .smart-modal-dialog {
  opacity: 1;
  transform: scale(1) translateY(0);
}

.smart-modal-dialog.wide {
  width: min(1100px, 100%);
}

[data-theme='light'] .smart-modal-dialog {
  background: #fff;
  border-color: rgba(168,120,36,0.25);
  box-shadow: var(--shadow-xl);
}

[data-theme='light'] .smart-modal-backdrop {
  background: rgba(0,0,0,0.38);
}

.smart-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
}

.smart-modal-header::after {
  content: '';
  position: absolute;
  bottom: 0; left: 22px; right: 22px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-light), transparent);
  opacity: 0.25;
}

.smart-modal-title-block {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}

.smart-modal-icon {
  width: 38px; height: 38px;
  border-radius: var(--r-sm);
  background: var(--gold-dim);
  border: 1px solid var(--border-gold);
  display: grid;
  place-items: center;
  color: var(--gold);
  font-size: 15px;
  flex-shrink: 0;
}

.smart-modal-title-block h3 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
  margin: 0;
  line-height: 1.25;
}

.smart-modal-title-block p {
  color: var(--muted);
  font-size: 12px;
  margin: 2px 0 0;
  line-height: 1;
}

.smart-modal-body {
  overflow-y: auto;
  overflow-x: hidden;
  padding: 22px;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: var(--border-md) transparent;
}

.smart-modal-body::-webkit-scrollbar { width: 4px; }
.smart-modal-body::-webkit-scrollbar-thumb { background: var(--border-md); border-radius: 2px; }

/* Forms inside modal */
.smart-modal-body .form-grid { gap: 14px; }
.smart-modal-body > form { display: grid; gap: 14px; }
.smart-modal-body .btn.btn-primary {
  margin-top: 6px;
  min-height: 44px;
  font-size: 14px;
  width: 100%;
  border-radius: var(--r-md);
}
.smart-modal-body .form-actions { flex-wrap: wrap; }
.smart-modal-body .form-actions .btn { flex: 1; justify-content: center; }

/* Responsive */
@media (max-width: 640px) {
  .smart-modal { padding: 12px; align-items: flex-end; }
  .smart-modal-dialog { border-radius: var(--r-xl) var(--r-xl) var(--r-md) var(--r-md); max-height: 96vh; width: 100%; }
  .smart-modal-dialog.wide { width: 100%; }
  .smart-modal-body { padding: 18px; }
  .smart-modal-header { padding: 16px 18px; }
}

/* =============================================
   PHOTO UPLOAD GRID (product images)
   ============================================= */
.photo-upload-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: block;
  margin-bottom: 10px;
}

.photo-upload-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

.photo-slot {
  aspect-ratio: 1;
  border-radius: var(--r-md);
  border: 1.5px dashed var(--border-md);
  background: var(--surface-light);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}

.photo-slot:hover {
  border-color: var(--gold);
  background: var(--gold-dim);
}

.photo-slot input[type="file"] {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  opacity: 0; cursor: pointer;
  z-index: 2; padding: 0;
  border: none; background: none;
}

.photo-slot-empty {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 5px;
  pointer-events: none;
}

.photo-slot-empty i {
  font-size: 20px;
  color: var(--muted);
  transition: color var(--transition);
}

.photo-slot:hover .photo-slot-empty i { color: var(--gold); }

.photo-slot-empty span {
  font-size: 10px;
  color: var(--muted);
  font-weight: 600;
  text-align: center;
  line-height: 1.2;
}

.photo-slot-empty .photo-slot-sub {
  font-size: 9px;
  color: var(--muted);
  opacity: 0.7;
}

.photo-slot-preview {
  position: absolute; inset: 0;
  z-index: 1;
}

.photo-slot-preview img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}

.photo-slot-preview .photo-remove-btn {
  position: absolute; top: 4px; right: 4px;
  width: 20px; height: 20px;
  border-radius: var(--r-full);
  background: rgba(0,0,0,0.65);
  border: none; cursor: pointer;
  color: #fff; font-size: 10px;
  display: grid; place-items: center;
  z-index: 3;
  transition: background var(--transition);
}

.photo-slot-preview .photo-remove-btn:hover { background: var(--red); }

.photo-slot.uploading .photo-slot-empty i { animation: spin 0.8s linear infinite; }

.photo-slot-progress {
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 3px;
  background: var(--gold);
  transform-origin: left;
  z-index: 4;
  transform: scaleX(0);
  transition: transform 0.3s var(--ease);
}

[data-theme='light'] .photo-slot {
  background: #f7f5f0;
  border-color: rgba(0,0,0,0.14);
}

@media (max-width: 480px) {
  .photo-upload-grid { grid-template-columns: repeat(3, 1fr); }
}

/* =============================================
   ATTACHMENT FIELD (financeiro)
   ============================================= */
.attachment-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.attachment-label {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 14px;
  border-radius: var(--r-sm);
  border: 1.5px dashed var(--border-md);
  background: var(--surface-light);
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), color var(--transition);
  position: relative;
  overflow: hidden;
}

.attachment-label input[type="file"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer;
  width: 100%; height: 100%; padding: 0; border: none; background: none;
}

.attachment-label:hover {
  border-color: var(--gold);
  background: var(--gold-dim);
  color: var(--gold);
}

.attachment-label i { font-size: 15px; flex-shrink: 0; }

.attachment-label .attachment-text { flex: 1; min-width: 0; }
.attachment-label .attachment-text small {
  display: block;
  font-size: 10px;
  margin-top: 1px;
  opacity: 0.75;
}

.attachment-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-gold);
  background: var(--gold-dim);
}

.attachment-preview-icon {
  width: 32px; height: 32px;
  border-radius: var(--r-xs);
  background: var(--gold);
  display: grid; place-items: center;
  color: #0a0c0b;
  font-size: 14px;
  flex-shrink: 0;
}

.attachment-preview a {
  flex: 1;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.attachment-preview a:hover { color: var(--gold); }

.attachment-remove-btn {
  width: 26px; height: 26px;
  border-radius: var(--r-xs);
  border: none; background: transparent;
  color: var(--muted); cursor: pointer;
  display: grid; place-items: center;
  font-size: 12px;
  flex-shrink: 0;
  transition: color var(--transition), background var(--transition);
}
.attachment-remove-btn:hover { color: var(--red); background: var(--red-dim); }

[data-theme='light'] .attachment-label {
  background: #f7f5f0;
  border-color: rgba(0,0,0,0.14);
}

/* Uploading spinner */
@keyframes spin { to { transform: rotate(360deg); } }

