:root {
  --navy: #172B46;
  --terracotta: #A85F43;
  --cream: #F3E9DC;
  --paper: #F8F5F1;
  --bg: #F4F7F9;
  --white: #FFFFFF;
  --text: #26313B;
  --muted: #6F747A;
  --line: #D8E2E6;
  --line-warm: #DEDBD6;
  --teal: #0C5967;
  --teal-2: #087F91;
  --success: #2F7D5A;
  --warning: #A56A17;
  --danger: #A84D43;
  --info: #386C91;
  --shadow: 0 12px 35px rgba(23,43,70,.08);
  --radius: 14px;
  --sidebar: 254px;
  --font-ui: Arial, system-ui, sans-serif;
  --font-display: Georgia, 'Times New Roman', serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-ui);
  color: var(--text);
  background: var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

/* =========================================================
   ESTRUTURA PRINCIPAL
   ========================================================= */

.app-shell {
  min-height: 100vh;
  display: flex;
}

.sidebar {
  width: var(--sidebar);
  background: var(--navy);
  color: #fff;
  padding: 24px 15px 16px;
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 2px 10px 26px;
}

.brand strong {
  display: block;
  letter-spacing: .16em;
  font-size: 15px;
}

.brand small {
  display: block;
  color: rgba(255,255,255,.62);
  margin-top: 4px;
  font-size: 11px;
}

.brand-mark {
  width: 31px;
  height: 31px;
  position: relative;
  border-left: 4px solid var(--terracotta);
  display: grid;
  place-items: center;
}

.brand-mark:before {
  content: "";
  width: 13px;
  height: 13px;
  border: 1px solid var(--cream);
  border-radius: 50%;
  opacity: .9;
}

.nav {
  display: grid;
  gap: 4px;
}

.nav-item {
  border: 0;
  color: rgba(255,255,255,.73);
  background: transparent;
  border-radius: 10px;
  padding: 11px 12px;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 11px;
  transition: .18s ease;
}

.nav-item span {
  width: 24px;
  text-align: center;
  opacity: .9;
  font-size: 14px;
}

.nav-item:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
}

.nav-item.active {
  background: rgba(243,233,220,.12);
  color: #fff;
  box-shadow: inset 3px 0 var(--terracotta);
}

.sidebar-bottom {
  margin-top: auto;
  border-top: 1px solid rgba(255,255,255,.10);
  padding-top: 13px;
}

.user-mini {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 8px 2px;
}

.user-mini strong {
  display: block;
  font-size: 13px;
}

.user-mini small {
  display: block;
  color: rgba(255,255,255,.55);
  font-size: 11px;
  margin-top: 3px;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--cream);
  color: var(--navy);
  font-weight: 700;
}

.avatar.small {
  width: 30px;
  height: 30px;
  font-size: 12px;
}

.main {
  margin-left: var(--sidebar);
  width: calc(100% - var(--sidebar));
  min-width: 0;
}

.topbar {
  height: 70px;
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.breadcrumb {
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--navy);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button,
.profile-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--navy);
  border-radius: 9px;
  min-height: 38px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.icon-button {
  width: 40px;
  position: relative;
}

.notification-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--terracotta);
  position: absolute;
  top: 8px;
  right: 9px;
}

.content {
  padding: 28px;
  max-width: 1500px;
  margin: 0 auto;
}

/* =========================================================
   LOGIN / AUTENTICAÇÃO
   ========================================================= */

.login-screen {
  min-height: 100vh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  background:
    radial-gradient(
      circle at top right,
      rgba(243,233,220,.75),
      transparent 34%
    ),
    linear-gradient(
      135deg,
      #f4f7f9 0%,
      #f8f5f1 100%
    );
}

.login-card {
  width: min(430px, 100%);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 24px 70px rgba(23,43,70,.12);
  padding: 38px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 34px;
}

.login-brand .brand-mark {
  flex: none;
}

.login-brand strong {
  display: block;
  color: var(--navy);
  letter-spacing: .16em;
  font-size: 16px;
}

.login-brand small {
  display: block;
  color: var(--muted);
  margin-top: 4px;
  font-size: 11px;
}

.login-card h1 {
  margin: 0;
  color: var(--navy);
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 600;
}

.login-subtitle {
  margin: 7px 0 28px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.login-card .field {
  margin-bottom: 17px;
}

.login-card .input {
  min-height: 46px;
  padding: 11px 13px;
}

.login-button {
  width: 100%;
  min-height: 46px;
  margin-top: 5px;
  font-size: 14px;
}

.login-message {
  margin-bottom: 18px;
  padding: 11px 13px;
  border-left: 3px solid var(--terracotta);
  background: var(--paper);
  border-radius: 7px;
  color: var(--text);
  font-size: 12px;
  line-height: 1.45;
}

.login-error {
  min-height: 20px;
  margin-top: 12px;
  color: var(--danger);
  font-size: 12px;
  line-height: 1.4;
}

/* =========================================================
   TÍTULOS / AÇÕES
   ========================================================= */

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.page-head h1 {
  font-family: var(--font-display);
  font-size: 30px;
  color: var(--navy);
  margin: 0 0 6px;
  font-weight: 600;
}

.page-head p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.actions {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
}

/* =========================================================
   BOTÕES
   ========================================================= */

.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--navy);
  border-radius: 9px;
  padding: 10px 14px;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 600;
}

.btn:hover {
  border-color: #bccbd1;
  box-shadow: 0 4px 12px rgba(23,43,70,.06);
}

.btn-primary {
  background: var(--terracotta);
  border-color: var(--terracotta);
  color: #fff;
}

.btn-primary:hover {
  background: #92513a;
}

.btn-dark {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}

.btn-danger {
  color: var(--danger);
}

/* =========================================================
   GRIDS / CARDS / KPIs
   ========================================================= */

.grid {
  display: grid;
  gap: 16px;
}

.kpi-grid {
  grid-template-columns: repeat(4,minmax(0,1fr));
}

.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 3px 14px rgba(23,43,70,.035);
}

.kpi {
  padding: 18px;
  position: relative;
  overflow: hidden;
}

.kpi:after {
  content: "";
  position: absolute;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  right: -26px;
  top: -27px;
  background: var(--cream);
  opacity: .55;
}

.kpi .label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.kpi .value {
  font-size: 27px;
  font-weight: 700;
  color: var(--navy);
  margin-top: 9px;
}

.kpi .sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}

.section-grid {
  display: grid;
  grid-template-columns: 1.45fr .85fr;
  gap: 16px;
  margin-top: 16px;
}

.card-head {
  padding: 17px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.card-head h2 {
  margin: 0;
  color: var(--navy);
  font-size: 15px;
}

.card-body {
  padding: 18px;
}

/* =========================================================
   ALERTAS
   ========================================================= */

.alert-list {
  display: grid;
  gap: 10px;
}

.alert {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.alert .mark {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  background: var(--terracotta);
  flex: none;
}

.alert.warning .mark {
  background: #C68A26;
}

.alert.danger .mark {
  background: var(--danger);
}

.alert.info .mark {
  background: var(--info);
}

.alert strong {
  font-size: 13px;
  display: block;
}

.alert small {
  color: var(--muted);
  display: block;
  margin-top: 3px;
  line-height: 1.35;
}

/* =========================================================
   TABELAS
   ========================================================= */

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 700px;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 13px;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  background: #fbfcfc;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover {
  background: #faf8f5;
}

/* =========================================================
   STATUS
   ========================================================= */

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 11px;
  font-weight: 700;
}

.status:before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status.novo {
  color: #386C91;
  background: #edf5fa;
}

.status.calculo {
  color: #0C5967;
  background: #eaf6f7;
}

.status.revisao {
  color: #765D94;
  background: #f3eff8;
}

.status.enviado {
  color: #2F7D5A;
  background: #edf7f1;
}

.status.atrasado {
  color: #A84D43;
  background: #fbefed;
}

.status.aguardando {
  color: #A56A17;
  background: #fbf5e9;
}

.status.concluido {
  color: #2F7D5A;
  background: #edf7f1;
}

/* =========================================================
   FORMULÁRIOS
   ========================================================= */

.muted {
  color: var(--muted);
}

.money {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--navy);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  padding: 14px;
  margin-bottom: 14px;
}

.input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--text);
  padding: 10px 11px;
  outline: none;
}

.input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal-2);
  box-shadow: 0 0 0 3px rgba(8,127,145,.10);
}

.filters .field {
  flex: 1 1 180px;
  min-width: 160px;
}

.filters .field.small {
  flex: 0 1 150px;
}

.field label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.empty {
  text-align: center;
  padding: 42px 18px;
  color: var(--muted);
}

/* =========================================================
   PERFIS / COLUNAS
   ========================================================= */

.two-col {
  grid-template-columns: 1fr 1fr;
}

.three-col {
  grid-template-columns: repeat(3,1fr);
}

.profile-card {
  padding: 20px;
  display: flex;
  gap: 15px;
  align-items: center;
}

.profile-card .avatar {
  width: 48px;
  height: 48px;
}

.person-meta h3 {
  margin: 0;
  color: var(--navy);
  font-size: 16px;
}

.person-meta p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.mini-stats {
  display: grid;
  grid-template-columns: repeat(3,1fr);
  gap: 10px;
  margin-top: 16px;
}

.mini-stat {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.mini-stat strong {
  display: block;
  font-size: 18px;
  color: var(--navy);
}

.mini-stat small {
  color: var(--muted);
}

/* =========================================================
   MODAIS
   ========================================================= */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16,29,43,.48);
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal {
  width: min(820px,100%);
  max-height: 92vh;
  overflow: auto;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 30px 80px rgba(0,0,0,.25);
}

.modal-head {
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-head h2 {
  margin: 0;
  font-family: var(--font-display);
  color: var(--navy);
  font-size: 22px;
}

.modal-body {
  padding: 20px;
}

.modal-foot {
  padding: 15px 20px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 9px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2,1fr);
  gap: 15px;
}

.form-grid .full {
  grid-column: 1/-1;
}

.close {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 24px;
  width: 36px;
  height: 36px;
}

/* =========================================================
   DRAWER / DETALHES
   ========================================================= */

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16,29,43,.28);
  z-index: 70;
}

.drawer {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: min(720px,100%);
  background: #fff;
  box-shadow: -25px 0 60px rgba(0,0,0,.15);
  overflow: auto;
}

.drawer-head {
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 2;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
}

.drawer-body {
  padding: 20px;
}

.detail-title {
  font-family: var(--font-display);
  color: var(--navy);
  font-size: 25px;
  margin: 0;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 18px;
}

.detail-box {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.detail-box small {
  color: var(--muted);
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  font-weight: 700;
  margin-bottom: 5px;
}

.detail-box strong {
  color: var(--navy);
  font-size: 13px;
}

/* =========================================================
   HISTÓRICO
   ========================================================= */

.timeline {
  position: relative;
  margin: 20px 0 0 7px;
  padding-left: 21px;
  border-left: 1px solid var(--line);
  display: grid;
  gap: 17px;
}

.event {
  position: relative;
}

.event:before {
  content: "";
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--terracotta);
  left: -25px;
  top: 4px;
  box-shadow: 0 0 0 4px #fff;
}

.event strong {
  font-size: 13px;
}

.event small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
  font-size: 11px;
}

/* =========================================================
   TOAST / AVISOS
   ========================================================= */

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 200;
  background: var(--navy);
  color: #fff;
  padding: 12px 15px;
  border-radius: 9px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: .2s;
  max-width: 360px;
  font-size: 13px;
}

.toast.show {
  opacity: 1;
  transform: none;
}

.mobile-only {
  display: none;
}

.kpi-link {
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--teal);
  font-weight: 700;
}

.notice {
  padding: 12px 14px;
  border-left: 3px solid var(--terracotta);
  background: var(--paper);
  color: #5b5d60;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.5;
}

/* =========================================================
   KANBAN
   ========================================================= */

.kanban {
  display: grid;
  grid-template-columns: repeat(4,minmax(240px,1fr));
  gap: 12px;
  overflow: auto;
  padding-bottom: 5px;
}

.kanban-col {
  background: #eef2f4;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  min-height: 420px;
}

.kanban-head {
  display: flex;
  justify-content: space-between;
  padding: 4px 3px 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--navy);
}

.kanban-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 9px;
  cursor: pointer;
}

.kanban-card:hover {
  box-shadow: 0 5px 15px rgba(23,43,70,.08);
}

.kanban-card strong {
  display: block;
  font-size: 13px;
  color: var(--navy);
}

.kanban-card small {
  display: block;
  color: var(--muted);
  margin-top: 5px;
  line-height: 1.4;
}

/* =========================================================
   RESPONSIVIDADE
   ========================================================= */

@media(max-width:1050px) {
  .kpi-grid {
    grid-template-columns: repeat(2,1fr);
  }

  .section-grid {
    grid-template-columns: 1fr;
  }
}

@media(max-width:800px) {
  :root {
    --sidebar: 0px;
  }

  .sidebar {
    transform: translateX(-100%);
    width: 270px;
    transition: .2s;
  }

  .sidebar.open {
    transform: none;
    box-shadow: 20px 0 50px rgba(0,0,0,.18);
  }

  .main {
    margin-left: 0;
    width: 100%;
  }

  .mobile-only {
    display: inline-flex;
  }

  .topbar {
    padding: 0 15px;
  }

  .content {
    padding: 20px 15px;
  }

  .page-head {
    flex-direction: column;
  }

  .page-head .actions {
    width: 100%;
  }

  .page-head .actions .btn {
    flex: 1;
  }

  .form-grid,
  .detail-grid,
  .two-col {
    grid-template-columns: 1fr;
  }

  .three-col {
    grid-template-columns: 1fr;
  }

  .desktop-only {
    display: none;
  }

  .kpi-grid {
    grid-template-columns: 1fr 1fr;
  }

  .mini-stats {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .login-screen {
    padding: 24px 16px;
  }

  .login-card {
    padding: 30px 24px;
  }
}

@media(max-width:520px) {
  .kpi-grid {
    grid-template-columns: 1fr 1fr;
    gap: 9px;
  }

  .kpi {
    padding: 14px;
  }

  .kpi .value {
    font-size: 21px;
  }

  .breadcrumb {
    font-size: 18px;
  }

  .profile-button {
    padding: 3px 7px;
  }

  .content {
    padding-top: 16px;
  }

  .mini-stats {
    grid-template-columns: 1fr;
  }

  .modal-backdrop {
    padding: 0;
  }

  .modal {
    height: 100%;
    max-height: none;
    border-radius: 0;
  }

  .drawer {
    width: 100%;
  }

  .login-screen {
    min-height: 100svh;
    padding: 16px;
  }

  .login-card {
    padding: 26px 20px;
    border-radius: 15px;
  }

  .login-brand {
    margin-bottom: 28px;
  }

  .login-card h1 {
    font-size: 30px;
  }
}
