:root {
  --black: #0b0d10;
  --graphite: #15191f;
  --panel-dark: #1c2128;
  --gold: #c9a227;
  --gold-soft: #ead98b;
  --gold-deep: #9b7612;
  --paper: #ffffff;
  --canvas: #f2f3f5;
  --ink: #17191d;
  --muted: #70747c;
  --line: #e1e3e7;
  --success: #39735a;
  --danger: #a53d3d;
  --shadow: 0 14px 34px rgba(15, 18, 22, .08);
  --radius: 14px;
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--canvas);
  font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }

.app-frame { min-height: 100vh; display: grid; grid-template-columns: 244px minmax(0, 1fr); }
.sidebar {
  position: sticky; top: 0; z-index: 30; height: 100vh; display: flex; flex-direction: column;
  padding: 26px 18px 18px; color: #fff; background:
    radial-gradient(circle at 10% 8%, rgba(201,162,39,.13), transparent 26%),
    linear-gradient(160deg, #0a0c0f, #15191f 70%);
  border-right: 1px solid rgba(255,255,255,.07);
}
.brand { display: flex; align-items: center; gap: 12px; margin: 0 8px 34px; }
.brand-mark {
  position: relative; width: 38px; height: 38px; flex: 0 0 38px;
  display: inline-block; border: 1px solid var(--gold);
  background:
    linear-gradient(90deg, transparent 30%, var(--gold) 31%, var(--gold) 34%, transparent 35%, transparent 65%, var(--gold) 66%, var(--gold) 69%, transparent 70%),
    linear-gradient(0deg, transparent 30%, var(--gold) 31%, var(--gold) 34%, transparent 35%, transparent 65%, var(--gold) 66%, var(--gold) 69%, transparent 70%);
}
.brand-mark::after {
  content: ""; position: absolute; right: -5px; bottom: -5px; width: 10px; height: 10px;
  background: var(--gold); border: 3px solid var(--black);
}
.brand strong { display: block; font-size: 16px; letter-spacing: .08em; text-transform: uppercase; }
.brand small { display: block; margin-top: 2px; color: rgba(255,255,255,.48); font-size: 9px; letter-spacing: .08em; text-transform: uppercase; }
.main-nav { display: flex; flex-direction: column; gap: 5px; }
.main-nav a {
  display: flex; align-items: center; gap: 11px; min-height: 44px; padding: 0 13px;
  color: rgba(255,255,255,.68); border-radius: 9px; font-weight: 650; transition: .16s ease;
}
.main-nav a:hover { color: #fff; background: rgba(255,255,255,.06); }
.main-nav a.active { color: #151515; background: var(--gold); box-shadow: 0 10px 24px rgba(201,162,39,.2); }
.nav-icon { width: 18px; color: currentColor; text-align: center; font-size: 17px; }
.nav-section { margin: 23px 13px 7px; color: rgba(255,255,255,.34); font-size: 9px; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 14px 10px 3px; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-foot strong, .sidebar-foot small { display: block; }
.sidebar-foot strong { color: rgba(255,255,255,.75); font-size: 10px; }
.sidebar-foot small { color: rgba(255,255,255,.37); font-size: 9px; }
.status-dot, .current-dot, .past-dot { width: 8px; height: 8px; flex: 0 0 8px; border-radius: 50%; background: #66a87d; box-shadow: 0 0 0 4px rgba(102,168,125,.12); }
.past-dot { background: #a4a6aa; box-shadow: none; }

.app-main { min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 20; min-height: 72px; display: flex; align-items: center;
  justify-content: space-between; gap: 20px; padding: 0 clamp(20px, 4vw, 46px);
  background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px);
}
.topbar-title p, .topbar-title strong { display: block; margin: 0; }
.topbar-title p { color: var(--muted); font-size: 9px; font-weight: 780; letter-spacing: .12em; text-transform: uppercase; }
.topbar-title strong { margin-top: 2px; font-size: 15px; }
.user-area { display: flex; align-items: center; gap: 9px; }
.user-area strong, .user-area small { display: block; }
.user-area strong { font-size: 11px; }
.user-area small { color: var(--muted); font-size: 9px; }
.user-avatar { width: 32px; height: 32px; display: grid; place-items: center; color: #171717; background: var(--gold); border-radius: 50%; font-weight: 800; }
.link-button { padding: 4px 0; color: var(--gold-deep); background: none; border: 0; cursor: pointer; font-size: 11px; font-weight: 750; }
.user-area .link-button { margin-left: 8px; }
.menu-toggle { display: none; width: 38px; height: 38px; border: 1px solid var(--line); background: #fff; border-radius: 8px; cursor: pointer; }
.content { width: min(1660px, 100%); margin: 0 auto; padding: clamp(24px, 4vw, 44px); }

.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.page-heading.compact { margin-bottom: 22px; }
.page-heading h1 { margin: 3px 0 5px; font-size: clamp(30px, 4vw, 46px); line-height: 1; letter-spacing: -.045em; }
.page-heading p { max-width: 720px; margin: 0; color: var(--muted); }
.eyebrow, .kicker { color: var(--gold-deep)!important; font-size: 9px!important; font-weight: 850; letter-spacing: .14em; text-transform: uppercase; }
.back-link { display: inline-block; margin-bottom: 13px; color: var(--gold-deep); font-size: 11px; font-weight: 750; }

.button {
  min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 0 17px; border: 1px solid transparent; border-radius: 999px; cursor: pointer;
  font-weight: 760; font-size: 12px; transition: transform .14s, box-shadow .14s, background .14s;
}
.button:hover { transform: translateY(-1px); }
.button-primary { color: #151515; background: var(--gold); box-shadow: 0 10px 24px rgba(201,162,39,.22); }
.button-primary:hover { background: #d4b23e; }
.button-dark { color: #fff; background: var(--black); }
.button-ghost { color: #3c4046; background: #fff; border-color: #d7d9de; }
.button-danger { color: #fff; background: #8f3333; box-shadow: 0 10px 24px rgba(143,51,51,.18); }
.button-danger:hover { background: #a53d3d; }
.button-wide { width: 100%; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric-card { position: relative; overflow: hidden; padding: 20px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.metric-card::after { content: ""; position: absolute; top: 0; right: 0; width: 50px; height: 2px; background: var(--gold); }
.metric-card span, .metric-card small { display: block; color: var(--muted); font-size: 10px; }
.metric-card span { font-weight: 760; letter-spacing: .04em; text-transform: uppercase; }
.metric-card strong { display: block; margin: 9px 0 2px; font-size: 30px; line-height: 1; letter-spacing: -.04em; }
.metric-card.accent { color: #fff; background: var(--graphite); border-color: var(--graphite); }
.metric-card.accent span, .metric-card.accent small { color: rgba(255,255,255,.55); }

.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.filter-panel { margin-bottom: 18px; padding: 18px; }
.filter-grid { display: grid; grid-template-columns: minmax(230px, 1.8fr) minmax(170px, 1.2fr) repeat(5, minmax(110px, .72fr)) auto; gap: 11px; align-items: end; }
.clients-filter { grid-template-columns: minmax(280px, 2fr) minmax(170px, .8fr) auto; }
.filter-grid label, .form-grid label, .form-stack label, .inline-select {
  display: block; color: #555a62; font-size: 10px; font-weight: 760; letter-spacing: .035em;
}
input, select, textarea {
  width: 100%; margin-top: 6px; color: var(--ink); background: #f8f8f9; border: 1px solid #d8dadd;
  border-radius: 8px; outline: 0; transition: border .15s, box-shadow .15s, background .15s;
}
input, select { min-height: 42px; padding: 0 11px; }
textarea { padding: 10px 11px; resize: vertical; }
input:focus, select:focus, textarea:focus { background: #fff; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,162,39,.14); }
label small { display: block; margin-top: 5px; color: var(--muted); font-size: 9px; font-weight: 500; letter-spacing: 0; }
label em { margin-left: 6px; padding: 3px 6px; color: #725a10; background: #f5e9b7; border-radius: 999px; font-size: 8px; font-style: normal; text-transform: uppercase; }
.filter-actions { display: flex; gap: 7px; }

.table-panel { overflow: hidden; }
.panel-heading { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 0 18px; border-bottom: 1px solid var(--line); }
.panel-heading strong, .panel-heading span { display: block; }
.panel-heading strong { font-size: 12px; }
.panel-heading span { margin-top: 2px; color: var(--muted); font-size: 9px; }
.inline-select { display: flex; align-items: center; gap: 7px; }
.inline-select select { width: auto; min-height: 32px; margin: 0; }
.table-scroll { overflow: auto; }
table { width: 100%; min-width: 1080px; border-collapse: collapse; }
th { padding: 12px 14px; color: #767b83; background: #fafafb; border-bottom: 1px solid var(--line); text-align: left; font-size: 9px; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }
td { padding: 13px 14px; border-bottom: 1px solid #eceef0; vertical-align: middle; font-size: 11px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fffcf2; }
td strong, td small { display: block; }
td strong { font-size: 11px; }
td small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.code { color: #775c0d; letter-spacing: .02em; }
.tag, .status, .count-badge { display: inline-flex; align-items: center; min-height: 25px; padding: 0 9px; border-radius: 999px; white-space: nowrap; font-size: 9px; font-weight: 720; }
.tag { color: #4f5359; background: #eff0f2; }
.status { color: #595d63; background: #f0f1f2; }
.status-disponivel-para-venda { color: #286148; background: #e3f2e9; }
.status-agenciado, .status-agenciado-com-exclusividade { color: #72550c; background: #faefc1; }
.status-a-agenciar { color: #7b4b26; background: #fae7d8; }
.count-badge { min-width: 28px; justify-content: center; color: #71570e; background: #f4e8b6; }
.table-action { color: var(--gold-deep); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.empty-state { padding: 40px; color: var(--muted); text-align: center; }
.pagination { min-height: 56px; display: flex; align-items: center; justify-content: center; gap: 20px; border-top: 1px solid var(--line); }
.pagination a { color: var(--gold-deep); font-size: 11px; font-weight: 750; }
.pagination span { color: var(--muted); font-size: 10px; }

.editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 18px; align-items: start; }
.form-panel { padding: clamp(20px, 3vw, 32px); }
.form-section-title { display: flex; align-items: center; gap: 11px; margin: 0 0 18px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.form-section-title:not(:first-child) { margin-top: 32px; }
.form-section-title > span { width: 28px; height: 28px; display: grid; place-items: center; color: #171717; background: var(--gold); border-radius: 7px; font-size: 9px; font-weight: 850; }
.form-section-title strong, .form-section-title small { display: block; }
.form-section-title strong { font-size: 13px; }
.form-section-title small { margin-top: 2px; color: var(--muted); font-size: 9px; font-weight: 500; }
.form-grid { display: grid; gap: 14px; }
.form-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-4 { grid-column: span 4; }
.editor-aside { display: grid; gap: 15px; }
.owner-panel, .history-panel { padding: 22px; }
.owner-panel h2, .history-panel h2 { margin: 3px 0 6px; font-size: 19px; }
.owner-panel > p:not(.kicker), .history-panel > p:not(.kicker) { margin: 0 0 18px; color: var(--muted); font-size: 10px; line-height: 1.6; }
.client-picker { position: relative; margin-bottom: 17px; }
.client-results { position: absolute; z-index: 10; top: 67px; left: 0; right: 0; overflow: auto; max-height: 260px; padding: 5px; background: #fff; border: 1px solid var(--line); border-radius: 9px; box-shadow: 0 16px 35px rgba(0,0,0,.15); }
.client-result { width: 100%; display: block; padding: 10px; color: var(--ink); background: #fff; border: 0; border-radius: 6px; text-align: left; cursor: pointer; }
.client-result:hover { background: #fff8df; }
.client-result strong, .client-result small { display: block; }
.client-result strong { font-size: 10px; }
.client-result small { margin-top: 2px; color: var(--muted); font-size: 9px; }
.client-result-empty { margin: 0; padding: 10px; color: var(--muted); font-size: 10px; }
.history-panel article { display: flex; align-items: flex-start; gap: 11px; padding: 11px 0; border-top: 1px solid var(--line); }
.history-panel article > span { margin-top: 5px; }
.history-panel strong, .history-panel small { display: block; }
.history-panel strong { font-size: 10px; }
.history-panel small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.history-panel a:hover strong { color: var(--gold-deep); }
.editor-footer { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 9px; padding: 17px 0 5px; }
.narrow-panel { max-width: 760px; padding: 28px; }
.admin-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.admin-card { padding: clamp(22px, 3vw, 30px); }
.admin-card h2 { margin: 4px 0 7px; font-size: 22px; letter-spacing: -.035em; }
.admin-card > p:not(.kicker) { margin: 0 0 22px; color: var(--muted); font-size: 10px; line-height: 1.65; }
.danger-card { border-color: #e2c7c7; }
.recovery-panel { margin-top: 18px; padding: 17px 20px; }
.recovery-panel strong { display: block; font-size: 11px; }
.recovery-panel p { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.callout { margin-bottom: 24px; padding: 16px 18px; background: #fbf6e1; border-left: 3px solid var(--gold); border-radius: 7px; }
.callout strong { font-size: 12px; }
.callout p { margin: 5px 0 0; color: #6f6650; font-size: 10px; }

.alert { margin: 0 0 18px; padding: 13px 16px; border-radius: 9px; font-size: 11px; font-weight: 650; }
.alert-success { color: #275b43; background: #e4f3e9; border: 1px solid #c4dfce; }
.alert-error { color: #833131; background: #f9e6e6; border: 1px solid #edc4c4; }
.empty-page { min-height: 55vh; display: grid; place-content: center; text-align: center; }
.empty-page span { color: var(--gold); font-size: 70px; font-weight: 850; }
.empty-page h1 { margin: 0; }
.empty-page p { color: var(--muted); }

.auth-page {
  min-height: 100vh; color: #fff; background:
    radial-gradient(circle at 12% 15%, rgba(201,162,39,.17), transparent 28%),
    linear-gradient(130deg, #090b0e 0%, #171b21 62%, #222831 100%);
}
.auth-shell, .setup-shell { width: min(1120px, calc(100% - 36px)); min-height: 100vh; margin: auto; display: grid; grid-template-columns: 1.1fr .8fr; gap: clamp(40px, 8vw, 100px); align-items: center; padding: 45px 0; }
.setup-shell { width: min(1180px, calc(100% - 36px)); grid-template-columns: .8fr 1.2fr; }
.auth-brand h1 { max-width: 660px; margin: 16px 0 18px; font-size: clamp(46px, 6vw, 78px); line-height: .94; letter-spacing: -.06em; }
.auth-brand h1 span { color: var(--gold); }
.auth-brand > p:not(.eyebrow) { max-width: 560px; color: rgba(255,255,255,.58); line-height: 1.7; }
.auth-features { margin: 28px 0 0; padding: 0; list-style: none; }
.auth-features li { margin: 10px 0; color: rgba(255,255,255,.68); font-size: 11px; }
.auth-features li::before { content: "◇"; margin-right: 9px; color: var(--gold); }
.auth-card { padding: clamp(26px, 4vw, 42px); color: var(--ink); background: rgba(255,255,255,.98); border: 1px solid rgba(201,162,39,.35); border-radius: 18px; box-shadow: 0 28px 70px rgba(0,0,0,.3); }
.auth-card header { margin-bottom: 24px; }
.auth-card h2 { margin: 4px 0 5px; font-size: 28px; letter-spacing: -.04em; }
.auth-card header p:not(.kicker), .auth-note { margin: 0; color: var(--muted); font-size: 10px; }
.form-stack { display: grid; gap: 16px; }
.section-rule { position: relative; margin: 8px 0 0; border-top: 1px solid var(--line); }
.section-rule span { position: relative; top: -8px; padding-right: 10px; color: var(--muted); background: #fff; font-size: 9px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.auth-note { margin-top: 18px; text-align: center; }

@media (max-width: 1180px) {
  .filter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filter-search { grid-column: span 2; }
  .filter-actions { justify-content: flex-end; }
  .form-grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-4 { grid-column: span 2; }
}
@media (max-width: 920px) {
  .app-frame { display: block; }
  .sidebar { position: fixed; left: -260px; width: 244px; transition: left .2s ease; box-shadow: 18px 0 50px rgba(0,0,0,.25); }
  .sidebar.open { left: 0; }
  .menu-toggle { display: block; }
  .topbar { justify-content: flex-start; }
  .user-area { margin-left: auto; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .editor-layout { grid-template-columns: 1fr; }
  .editor-footer { grid-column: 1; }
  .auth-shell, .setup-shell { grid-template-columns: 1fr; gap: 35px; padding: 45px 0; }
  .admin-grid { grid-template-columns: 1fr; }
  .auth-brand h1 { font-size: 50px; }
}
@media (max-width: 640px) {
  .content { padding: 22px 14px; }
  .topbar { padding: 0 14px; }
  .topbar-title { display: none; }
  .user-area > div { display: none; }
  .page-heading { align-items: stretch; flex-direction: column; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric-card { padding: 15px; }
  .metric-card strong { font-size: 24px; }
  .filter-grid, .clients-filter { grid-template-columns: 1fr; }
  .filter-search { grid-column: auto; }
  .filter-actions .button { flex: 1; }
  .form-grid.cols-4, .form-grid.cols-2 { grid-template-columns: 1fr; }
  .span-2, .span-4 { grid-column: auto; }
  .editor-footer .button { flex: 1; }
  .auth-card { padding: 25px 20px; }
  .auth-brand h1 { font-size: 42px; }
}
