:root {
  --bg-app: #F5F6F8;
  --bg-surface: #FFFFFF;
  --bg-sidebar: #12161B;
  --bg-sidebar-hover: #1B222A;
  --bg-sidebar-active: #232B34;

  --text-primary: #171A1F;
  --text-secondary: #667085;
  --text-muted: #98A2B3;
  --text-on-dark: #F2F4F7;
  --text-on-dark-muted: #98A2B3;

  --border: #E4E7EC;
  --border-strong: #D0D5DD;

  --accent: #FFC400;
  --accent-hover: #E6B000;
  --accent-soft: #FFF7D6;
  --accent-ink: #171A1F;

  --success: #12B76A;
  --success-soft: #ECFDF3;
  --warning: #F79009;
  --warning-soft: #FFFAEB;
  --danger: #D92D20;
  --danger-soft: #FEF3F2;
  --info: #2E90FA;
  --info-soft: #EFF8FF;

  --sidebar-width: 256px;
  --sidebar-collapsed: 72px;
  --topbar-height: 64px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow: 0 4px 16px rgba(16, 24, 40, .06);
  --focus: 0 0 0 3px rgba(46, 144, 250, .35);

  --font: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  /* Compatibilidade com classes antigas */
  --primary: var(--text-primary);
  --cyan: var(--info);
  --yellow: var(--accent);
  --green: var(--success);
  --text: var(--text-primary);
  --gray: var(--text-secondary);
  --bg: var(--bg-app);
  --card: var(--bg-surface);
}

*, *::before, *::after { box-sizing: border-box; }

html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--text-primary); }

:focus-visible {
  outline: 2px solid var(--info);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -40px;
  z-index: 100;
  background: var(--accent);
  color: var(--accent-ink);
  padding: .45rem .8rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus { top: 12px; }

/* ——— Shell ——— */
.layout {
  display: flex;
  min-height: 100vh;
  background: var(--bg-app);
}

.sidebar {
  flex: 0 0 var(--sidebar-width);
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  color: var(--text-on-dark);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  transition: width .2s ease, flex-basis .2s ease;
  z-index: 30;
}

.sidebar.collapsed {
  flex-basis: var(--sidebar-collapsed);
  width: var(--sidebar-collapsed);
}

.brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1.1rem 1rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.06);
  min-height: var(--topbar-height);
}
.brand img {
  display: none;
}
.brand-mark {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: .78rem;
  letter-spacing: -.03em;
}
.brand-text { min-width: 0; }
.brand strong {
  display: block;
  font-size: .95rem;
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.2;
}
.brand span {
  display: block;
  font-size: .72rem;
  color: var(--text-on-dark-muted);
  margin-top: .1rem;
}
.sidebar.collapsed .brand { justify-content: center; padding-inline: .6rem; }
.sidebar.collapsed .brand-text { display: none; }

.sidebar-nav {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: .85rem .7rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 99px; }

.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-group-label {
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #667085;
  padding: .35rem .7rem .45rem;
}
.sidebar.collapsed .nav-group-label { display: none; }

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: .7rem;
  color: #D0D5DD;
  text-decoration: none;
  padding: .55rem .7rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 500;
  min-height: 40px;
  position: relative;
}
.sidebar-nav a .icon { width: 18px; height: 18px; flex: 0 0 18px; opacity: .9; }
.sidebar-nav a:hover { background: var(--bg-sidebar-hover); color: #fff; }
.sidebar-nav a.active {
  background: var(--bg-sidebar-active);
  color: #fff;
  font-weight: 600;
}
.sidebar-nav a.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}
.sidebar.collapsed .sidebar-nav a {
  justify-content: center;
  padding: .65rem;
}
.sidebar.collapsed .sidebar-nav a span,
.sidebar.collapsed .sidebar-nav a .nav-label { display: none; }

.shell {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  gap: .85rem;
  min-height: var(--topbar-height);
  padding: 0 1.5rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar h1 { display: none; }

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: .4rem;
  min-width: 0;
  font-size: .875rem;
  color: var(--text-secondary);
}
.breadcrumbs a {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
}
.breadcrumbs a:hover { color: var(--text-primary); }
.crumb-sep { color: var(--text-muted); }
.crumb-current {
  color: var(--text-primary);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search {
  margin-left: auto;
  position: relative;
  min-width: 0;
}
.search .icon {
  position: absolute;
  left: .7rem;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}
.search input {
  width: min(340px, 36vw);
  min-width: 180px;
  height: 38px;
  padding: 0 .8rem 0 2.1rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-app);
}
.search input:focus {
  outline: none;
  border-color: var(--info);
  box-shadow: var(--focus);
  background: #fff;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-shrink: 0;
}

.user-menu { position: relative; }
.user-menu-toggle {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  background: transparent;
  border: 0;
  padding: .25rem .35rem .25rem .25rem;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
}
.user-menu-toggle:hover { background: var(--bg-app); }
.user-menu-toggle .icon { width: 14px; height: 14px; color: var(--text-muted); }
.user-meta { text-align: left; }
.user-meta strong, .user-area strong { display: block; font-size: .8125rem; line-height: 1.2; }
.user-meta small, .user-area small { display: block; color: var(--text-secondary); font-size: .72rem; }
.user-avatar {
  display: inline-grid;
  place-items: center;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--text-primary);
  color: var(--accent);
  font-weight: 700;
  font-size: .75rem;
}
.user-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 200px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: .35rem;
  z-index: 40;
}
.user-menu.is-open .user-dropdown { display: block; }
.user-dropdown a,
.user-dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  padding: .55rem .7rem;
  border-radius: 6px;
  font-size: .875rem;
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 500;
}
.user-dropdown a:hover,
.user-dropdown button:hover { background: var(--bg-app); }

.user-area {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  color: var(--text-primary);
  text-decoration: none;
  padding: .25rem .45rem;
  border-radius: var(--radius-sm);
}
.user-area:hover { background: var(--bg-app); }

.content {
  flex: 1 1 auto;
  padding: 1.5rem 1.75rem 2.5rem;
  max-width: 1440px;
  width: 100%;
}

.sidebar-backdrop {
  display: none;
}

/* ——— Page header ——— */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.page-title {
  margin: 0;
  font-size: 1.75rem;
  line-height: 1.2;
  letter-spacing: -.03em;
  font-weight: 700;
}
.page-description, .page-lede {
  margin: .35rem 0 0;
  color: var(--text-secondary);
  font-size: .9rem;
  max-width: 46rem;
}
.page-header-actions {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  align-items: center;
}

/* ——— Buttons ——— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: .5rem 1rem;
  min-height: 38px;
  cursor: pointer;
  text-decoration: none;
  font-weight: 600;
  font-size: .875rem;
  line-height: 1.2;
  white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s;
}
.btn .icon { width: 16px; height: 16px; }
.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-secondary {
  background: #fff;
  color: var(--text-primary);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--bg-app); }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { filter: brightness(.95); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { filter: brightness(.95); }
.btn-link {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-link:hover { background: var(--bg-app); color: var(--text-primary); }
.btn-icon {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0;
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  color: var(--text-primary);
}
.btn-icon .icon { width: 18px; height: 18px; }
.btn-icon:hover { background: var(--bg-app); }
.btn:disabled, .btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ——— Cards / KPIs ——— */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.2rem;
  box-shadow: var(--shadow-sm);
}
.card h2, .card > h3 {
  margin: 0 0 .75rem;
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: -.02em;
}
.card-lede {
  margin: -.45rem 0 1rem;
  color: var(--text-secondary);
  font-size: .825rem;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: .85rem;
  margin: 0 0 1.25rem;
}

.kpi-card, .stat {
  display: flex;
  flex-direction: column;
  gap: .2rem;
  text-decoration: none;
  color: inherit;
  min-height: 108px;
}
a.kpi-card:hover, a.stat:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.kpi-label, .stat span {
  color: var(--text-secondary);
  font-size: .8rem;
  font-weight: 600;
}
.kpi-value, .stat strong {
  display: block;
  font-size: 1.75rem;
  letter-spacing: -.04em;
  color: var(--text-primary);
  font-weight: 700;
  line-height: 1.15;
}
.kpi-hint {
  margin-top: auto;
  font-size: .75rem;
  color: var(--text-muted);
}
.kpi-card.is-warning { background: var(--warning-soft); border-color: #FEDF89; }
.kpi-card.is-danger { background: var(--danger-soft); border-color: #FECDCA; }
.kpi-card.is-success { background: var(--success-soft); border-color: #A6F4C5; }
.kpi-card.is-warning .kpi-value { color: #B54708; }
.kpi-card.is-danger .kpi-value { color: var(--danger); }
.kpi-card.is-success .kpi-value { color: #027A48; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.grid-os {
  display: grid;
  grid-template-columns: 1.4fr .9fr;
  gap: 1rem;
}

/* ——— Flow track ——— */
.flow-track {
  list-style: none;
  margin: 0 0 1.25rem;
  padding: 0;
  display: flex;
  gap: .5rem;
  overflow-x: auto;
}
.flow-track li { flex: 1 1 0; min-width: 120px; position: relative; }
.flow-track a, .flow-step {
  display: flex;
  flex-direction: column;
  gap: .15rem;
  padding: .9rem 1rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  min-height: 92px;
}
.flow-track a:hover { border-color: var(--border-strong); }
.flow-count { font-size: 1.35rem; font-weight: 700; letter-spacing: -.03em; }
.flow-label { font-size: .78rem; color: var(--text-secondary); font-weight: 600; }
.flow-track li:not(:last-child)::after {
  content: "→";
  position: absolute;
  right: -.15rem;
  top: 50%;
  transform: translate(50%, -50%);
  color: var(--text-muted);
  font-size: .85rem;
  z-index: 1;
  background: var(--bg-app);
  padding: 0 .1rem;
}

.shortcuts {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: 1.25rem;
}

.section-title {
  margin: 0 0 .75rem;
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: -.02em;
}

/* ——— Tables ——— */
.table-card { padding: 0; overflow: hidden; }
.table-wrap { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.table th, .table td {
  padding: .85rem 1.1rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}
.table th {
  font-size: .72rem;
  font-weight: 650;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-secondary);
  background: #FAFBFC;
  white-space: nowrap;
}
.table tbody tr { height: 52px; }
.table tbody tr:hover { background: #FAFBFC; }
.table tbody tr:last-child td { border-bottom: 0; }
.table a {
  color: var(--text-primary);
  font-weight: 600;
  text-decoration: none;
}
.table a:hover { text-decoration: underline; text-underline-offset: 2px; }
.table-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .75rem 1.1rem;
  border-top: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: .8rem;
}
.pagination-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
  width: 100%;
}
.pagination-meta { color: var(--text-secondary); font-size: .8rem; }
.pagination {
  display: flex;
  align-items: center;
  gap: .35rem;
  flex-wrap: wrap;
}
.pagination-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 34px;
  padding: 0 .7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text-primary);
  font-size: .8rem;
  font-weight: 600;
  text-decoration: none;
}
.pagination-btn:hover { background: var(--bg-app); text-decoration: none; }
.pagination-btn.is-current {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.pagination-btn.is-disabled {
  opacity: .45;
  pointer-events: none;
}
.pagination-ellipsis {
  padding: 0 .25rem;
  color: var(--text-secondary);
}

.filter-bar, .filters, .toolbar {
  display: flex;
  gap: .75rem;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.filter-bar, .filters {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .85rem 1rem;
  box-shadow: var(--shadow-sm);
}
.filters label, .filter-bar label, .form-card label, .login-card label {
  display: grid;
  gap: .35rem;
  color: var(--text-secondary);
  font-size: .8rem;
  font-weight: 600;
}
.filters input, .filters select,
.filter-bar input, .filter-bar select {
  min-height: 38px;
  padding: .45rem .65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  min-width: 160px;
}
.filter-actions { display: flex; gap: .5rem; align-items: center; }
.full-width { grid-column: 1 / -1; }

/* ——— Forms ——— */
.form-card label { margin-bottom: 0; }
.form-card input, .form-card select, .form-card textarea,
.login-card input {
  width: 100%;
  margin-top: 0;
  padding: .55rem .7rem;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
}
.form-card textarea, textarea { min-height: 88px; resize: vertical; }
.form-card input:focus, .form-card select:focus, .form-card textarea:focus,
.login-card input:focus, .filters input:focus, .filters select:focus {
  outline: none;
  border-color: var(--info);
  box-shadow: var(--focus);
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: .9rem .85rem;
}
.form-section { margin-bottom: 1.25rem; }
.form-section h2 {
  margin: 0 0 .25rem;
  font-size: 1.05rem;
}
.form-section .hint { margin: 0 0 .85rem; }
.form-actions {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  margin-top: 1.15rem;
  position: sticky;
  bottom: 0;
  background: linear-gradient(180deg, transparent, var(--bg-app) 18%);
  padding: .85rem 0 .15rem;
}
.field-help, .hint {
  color: var(--text-secondary);
  font-size: .82rem;
  font-weight: 400;
}
.checkbox { font-weight: 500; display: flex !important; flex-direction: row; align-items: center; gap: .5rem; }
.checkbox input { width: auto; min-height: 0; margin: 0; }
.section-spaced { margin-top: 1.15rem; }

.item-editor { border: 0; padding: 0; margin: 0; }
.item-editor-heading { display: flex; justify-content: space-between; align-items: start; gap: .75rem; margin-bottom: .75rem; }
.item-editor h2 { color: var(--text-primary); font-size: 1.05rem; margin: 0; }
.item-row {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin: 0 0 .75rem;
  padding: .75rem 1rem 1rem;
  background: #FAFBFC;
}
.item-row legend { color: var(--text-primary); font-weight: 700; padding: 0 .25rem; }
.item-grid { display: grid; grid-template-columns: repeat(4, minmax(130px, 1fr)); gap: .5rem .75rem; }
.item-remove { display: flex; align-items: end; padding-bottom: .35rem; }

/* ——— Badges / flash / empty ——— */
.badge {
  display: inline-flex;
  align-items: center;
  background: var(--info-soft);
  color: #175CD3;
  padding: .15rem .55rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 650;
  white-space: nowrap;
}
.status-pill { font-weight: 650; }
.status-pill.status-received { background: var(--info-soft); color: #175CD3; }
.status-pill.status-diagnosing { background: var(--warning-soft); color: #B54708; }
.status-pill.status-awaiting_approval { background: #FFF6ED; color: #C4320A; }
.status-pill.status-approved { background: var(--success-soft); color: #027A48; }
.status-pill.status-in_progress { background: #F0F9FF; color: #026AA2; }
.status-pill.status-awaiting_part { background: var(--danger-soft); color: var(--danger); }
.status-pill.status-ready { background: var(--success-soft); color: #027A48; }
.status-pill.status-delivered { background: #F2F4F7; color: var(--text-secondary); }
.status-pill.status-cancelled { background: var(--danger-soft); color: var(--danger); }
.status-pill.status-new { background: var(--info-soft); color: #175CD3; }
.status-pill.status-under_review { background: var(--warning-soft); color: #B54708; }
.status-pill.status-awaiting_information { background: #FFF6ED; color: #C4320A; }
.status-pill.status-ready_for_quote { background: #F0F9FF; color: #026AA2; }
.status-pill.status-quoted { background: var(--success-soft); color: #027A48; }
.status-pill.status-converted_to_service_order { background: #F2F4F7; color: var(--text-secondary); }
.status-pill.status-available { background: var(--success-soft); color: #027A48; }
.status-pill.status-in_use { background: var(--info-soft); color: #175CD3; }
.status-pill.status-maintenance,
.status-pill.status-calibration { background: var(--warning-soft); color: #B54708; }
.status-pill.status-damaged { background: var(--danger-soft); color: var(--danger); }
.status-pill.status-inactive { background: #F2F4F7; color: var(--text-secondary); }
.status-pill.status-quote-draft { background: #F2F4F7; color: var(--text-secondary); }
.status-pill.status-quote-issued,
.status-pill.status-quote-sent { background: var(--info-soft); color: #175CD3; }
.status-pill.status-quote-approved { background: var(--success-soft); color: #027A48; }
.status-pill.status-quote-rejected,
.status-pill.status-quote-cancelled { background: var(--danger-soft); color: var(--danger); }
.status-pill.status-quote-expired { background: var(--warning-soft); color: #B54708; }

.flash-group { margin-bottom: 1rem; display: grid; gap: .45rem; }
.flash {
  padding: .7rem .95rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: .875rem;
}
.flash-success { background: var(--success-soft); color: #027A48; border-color: #A6F4C5; }
.flash-error { background: var(--danger-soft); color: var(--danger); border-color: #FECDCA; }
.flash-warning { background: var(--warning-soft); color: #B54708; border-color: #FEDF89; }
.flash-info { background: var(--info-soft); color: #175CD3; border-color: #B2DDFF; }

.empty { color: var(--text-secondary); font-style: normal; }
.empty-state {
  text-align: center;
  padding: 2.5rem 1.5rem;
}
.empty-state-title { margin: 0; font-size: 1.05rem; font-weight: 650; }
.empty-state-text { margin: .35rem 0 1rem; color: var(--text-secondary); }

.inline-form { display: inline; }
.hero-actions { display: flex; gap: .75rem; margin-bottom: 1rem; }

.account-card { max-width: 760px; }
.account-heading { display: flex; align-items: center; gap: .75rem; margin-bottom: 1rem; }
.account-heading h2 { margin: 0; }

.admin-card { display: block; color: inherit; text-decoration: none; transition: box-shadow .15s, transform .15s; }
.admin-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.admin-card h2 { margin: 0 0 .35rem; font-size: 1.05rem; }
.admin-card p { margin: 0; color: var(--text-secondary); font-size: .9rem; }
.masked-key { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .04em; }
.role-badge { text-transform: capitalize; }
.role-badge.master { background: var(--accent-soft); color: #93370D; }

/* ——— Tabs ——— */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin: 0 0 1.15rem;
  overflow-x: auto;
}
.tabs [role="tab"] {
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: .7rem .95rem;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: .875rem;
  white-space: nowrap;
  margin-bottom: -1px;
}
.tabs [role="tab"]:hover { color: var(--text-primary); }
.tabs [role="tab"][aria-selected="true"] {
  color: var(--text-primary);
  border-bottom-color: var(--accent);
}
.tab-panel { animation: fade .15s ease; }
@keyframes fade { from { opacity: .4; } to { opacity: 1; } }

/* ——— OS header ——— */
.os-header {
  display: flex;
  flex-direction: column;
  gap: .85rem;
  margin-bottom: 1.15rem;
}
.os-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}
.os-kicker {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: .825rem;
  font-weight: 600;
  margin-bottom: .35rem;
}
.os-kicker:hover { color: var(--text-primary); }
.os-title {
  margin: 0;
  font-size: 1.75rem;
  letter-spacing: -.03em;
  font-weight: 700;
  line-height: 1.15;
}
.os-sub {
  margin: .3rem 0 0;
  color: var(--text-secondary);
  font-size: .95rem;
}
.os-header-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.meta-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .75rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .85rem 1rem;
}
.meta-strip dt {
  font-size: .72rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  margin: 0;
}
.meta-strip dd {
  margin: .2rem 0 0;
  font-weight: 600;
  font-size: .9rem;
}
.dl-grid {
  display: grid;
  grid-template-columns: 8.5rem 1fr;
  gap: .45rem .75rem;
  margin: 0;
}
.dl-grid dt { color: var(--text-secondary); font-weight: 600; font-size: .82rem; }
.dl-grid dd { margin: 0; }
.money-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .75rem;
}
.money-row div {
  background: var(--bg-app);
  border-radius: var(--radius-sm);
  padding: .75rem .9rem;
}
.money-row span { display: block; font-size: .75rem; color: var(--text-secondary); font-weight: 600; }
.money-row strong { font-size: 1.15rem; letter-spacing: -.02em; }
.complaint-box, .prose-block {
  background: var(--bg-app);
  border-radius: var(--radius-sm);
  padding: .85rem 1rem;
  min-height: 4.5rem;
  white-space: pre-wrap;
}

/* ——— Timeline / photos ——— */
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0; }
.timeline li {
  position: relative;
  padding: .15rem 0 .85rem 1.15rem;
  border-left: 2px solid var(--border);
  margin-left: .4rem;
}
.timeline li::before {
  content: "";
  position: absolute;
  left: -5px;
  top: .45rem;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px #fff;
}
.timeline time { color: var(--text-muted); font-size: .78rem; display: block; }
.timeline strong { font-size: .875rem; }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .85rem; }
.photo-item {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .5rem;
  background: #fff;
}
.photo-item img {
  width: 100%;
  height: 132px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
}
.photo-item figcaption { font-size: .78rem; color: var(--text-secondary); margin-top: .4rem; }
.photo-actions { display: flex; flex-direction: column; gap: .35rem; margin-top: .35rem; }
.photo-actions select { font-size: .8rem; }
.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 1.25rem;
  background: #FAFBFC;
  text-align: center;
}
.dropzone.is-dragover { border-color: var(--accent); background: var(--accent-soft); }

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, .78);
  display: none;
  place-items: center;
  z-index: 80;
  padding: 2rem;
}
.lightbox.is-open { display: grid; }
.lightbox img { max-width: min(92vw, 1100px); max-height: 88vh; border-radius: 8px; }
.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 0;
  background: #fff;
  font-size: 1.2rem;
}

details summary {
  cursor: pointer;
  color: var(--text-primary);
  font-weight: 600;
  margin: .5rem 0;
  list-style: none;
}
details summary::-webkit-details-marker { display: none; }
details summary::before { content: "▸ "; color: var(--text-muted); }
details[open] summary::before { content: "▾ "; }
details[open] summary { margin-bottom: .75rem; }

hr { border: 0; border-top: 1px solid var(--border); margin: 1.25rem 0; }

/* ——— Integrações ——— */
.integration-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
.integration-card h2 { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.status-dot {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .78rem;
  font-weight: 650;
}
.status-dot::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}
.status-dot.is-on::before { background: var(--success); }
.status-dot.is-off::before { background: var(--text-muted); }

/* ——— Auth ——— */
.login-page {
  display: grid;
  min-height: 100vh;
  grid-template-columns: minmax(280px, 1fr) minmax(320px, 1fr);
  background: var(--bg-app);
}
.login-brand {
  background: var(--bg-sidebar);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 2.5rem 3rem;
}
.login-brand .brand-mark {
  width: 48px;
  height: 48px;
  font-size: 1rem;
}
.login-brand h1 {
  margin: 1.25rem 0 .5rem;
  font-size: 2rem;
  letter-spacing: -.03em;
}
.login-brand p {
  margin: 0;
  max-width: 18rem;
  color: #D0D5DD;
  font-size: 1.05rem;
}
.login-brand-foot { color: #667085; font-size: .8rem; }
.login-panel {
  display: grid;
  place-items: center;
  padding: 2rem;
}
.login-card {
  width: min(100%, 400px);
  background: #fff;
  padding: 2rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.login-card h1, .login-card h2 {
  color: var(--text-primary);
  margin: 0 0 .35rem;
  font-size: 1.5rem;
  letter-spacing: -.03em;
}
.login-card > p { margin: 0 0 1.25rem; color: var(--text-secondary); }
.login-card label { margin: 0 0 .85rem; }
.login-card .btn { width: 100%; margin-top: .35rem; }
.login-card a { color: var(--text-secondary); text-decoration: none; }
.login-card a:hover { color: var(--text-primary); text-decoration: underline; }

.validation-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 1rem;
  background: var(--bg-app);
}
.validation-page .card { width: min(100%, 440px); }

/* ——— Responsive ——— */
@media (max-width: 1100px) {
  .grid-os, .meta-strip, .money-row, .integration-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 960px) {
  .grid-2, .grid-os, .integration-grid, .meta-strip, .money-row { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: none;
  }
  .sidebar.is-open { transform: translateX(0); box-shadow: var(--shadow); }
  .sidebar.collapsed { flex-basis: var(--sidebar-width); width: var(--sidebar-width); }
  .sidebar.collapsed .brand-text,
  .sidebar.collapsed .nav-group-label,
  .sidebar.collapsed .sidebar-nav a span { display: revert; }
  .sidebar.collapsed .sidebar-nav a { justify-content: flex-start; padding: .55rem .7rem; }
  .sidebar-backdrop.is-visible {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(16, 24, 40, .45);
    z-index: 25;
  }
  .search input { width: 180px; min-width: 0; }
  .login-page { grid-template-columns: 1fr; }
  .login-brand { display: none; }
}
@media (max-width: 700px) {
  .content { padding: 1rem 1rem 2rem; }
  .topbar { padding: 0 .85rem; flex-wrap: wrap; min-height: 56px; }
  .search { margin-left: 0; flex: 1 1 100%; order: 5; }
  .search input { width: 100%; }
  .page-header, .os-header-top { flex-direction: column; }
  .table { display: block; overflow-x: auto; }
  .item-grid { grid-template-columns: 1fr 1fr; }
  .item-editor-heading { align-items: stretch; flex-direction: column; }
  .user-meta { display: none; }
  .form-actions { position: static; }
  .page-title, .os-title { font-size: 1.45rem; }
}

@media print {
  .sidebar, .topbar, .tabs, .btn, .form-actions { display: none !important; }
  .content { padding: 0; max-width: none; }
}
