/* ─── Design tokens ─────────────────────────────────────────────────────────── */
:root {
  --teal:       #1F6B6A;
  --teal-dark:  #165654;
  --teal-light: #e8f4f4;
  --teal-mist:  #f0f7f7;
  --ink:        #1A2A2A;
  --graphite:   #3D4F4E;
  --ghost:      #6b7e7e;
  --border:     #d4e2e2;
  --bg:         #f5f8f8;
  --white:      #ffffff;
  --red:        #C0392B;
  --red-light:  #fdf2f2;
  --green:      #1a7a4a;
  --green-light:#edfaf4;
  --yellow:     #b45309;
  --yellow-light:#fffbeb;
  --radius:     10px;
  --shadow:     0 2px 8px rgba(0,0,0,.08);
  --shadow-md:  0 4px 16px rgba(0,0,0,.10);
}

/* ─── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { font-family: 'Inter', system-ui, sans-serif; background: var(--bg); color: var(--ink); line-height: 1.55; }
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }
ul { list-style: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ─── Typography ─────────────────────────────────────────────────────────────── */
h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; }
h2 { font-size: 1.25rem; font-weight: 700; letter-spacing: -.015em; }
h3 { font-size: 1.05rem; font-weight: 600; }

/* ─── Layout ─────────────────────────────────────────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px; min-height: 100vh;
  background: var(--ink);
  color: #fff;
  display: flex; flex-direction: column;
  flex-shrink: 0;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-logo .brand { font-size: .75rem; font-weight: 600; letter-spacing: .16em; opacity: .55; margin-top: 4px; }
.sidebar-logo .name  { font-size: 1.05rem; font-weight: 700; }
.sidebar-nav { flex: 1; padding: 16px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px;
  font-size: .875rem; font-weight: 500; color: rgba(255,255,255,.7);
  transition: background .15s, color .15s;
}
.nav-item:hover, .nav-item.active { background: rgba(255,255,255,.1); color: #fff; text-decoration: none; }
.nav-item svg { opacity: .7; flex-shrink: 0; }
.nav-item:hover svg, .nav-item.active svg { opacity: 1; }
.sidebar-footer { padding: 16px 10px; border-top: 1px solid rgba(255,255,255,.08); }
.user-info { padding: 8px 12px; border-radius: 8px; font-size: .8rem; }
.user-info .user-name { font-weight: 600; color: #fff; }
.user-info .user-role { color: rgba(255,255,255,.5); font-size: .73rem; margin-top: 1px; }
.btn-logout {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px; border-radius: 8px; margin-top: 6px;
  font-size: .8rem; font-weight: 500; color: rgba(255,255,255,.6);
  background: none; border: none;
  width: 100%; transition: background .15s, color .15s;
}
.btn-logout:hover { background: rgba(255,255,255,.08); color: rgba(255,255,255,.9); }

.main-content { flex: 1; overflow-y: auto; }
.page-header {
  background: var(--white); border-bottom: 1px solid var(--border);
  padding: 20px 32px; display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
}
.page-body { padding: 28px 32px; max-width: 1100px; }

/* ─── Cards ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
  box-shadow: var(--shadow);
}
.card-sm { padding: 16px 20px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.card-title { font-size: 1rem; font-weight: 700; }

/* ─── Stat cards ─────────────────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 28px; }
.stat-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.stat-label { font-size: .75rem; font-weight: 600; letter-spacing: .08em; color: var(--ghost); margin-bottom: 8px; }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--teal); letter-spacing: -.03em; line-height: 1; }
.stat-sub   { font-size: .75rem; color: var(--ghost); margin-top: 4px; }

/* ─── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 8px; font-size: .875rem; font-weight: 600;
  border: none; transition: all .15s;
}
.btn-primary   { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-dark); }
.btn-secondary { background: var(--white); color: var(--ink); border: 1.5px solid var(--border); }
.btn-secondary:hover { border-color: var(--teal); color: var(--teal); }
.btn-danger    { background: var(--red-light); color: var(--red); border: 1px solid #f5c6c3; }
.btn-danger:hover { background: #f8d7d4; }
.btn-sm { padding: 7px 12px; font-size: .8rem; border-radius: 6px; }
.btn-icon { padding: 8px; border-radius: 8px; }
.btn:disabled { opacity: .5; pointer-events: none; }

/* ─── Forms ──────────────────────────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-full { grid-column: 1 / -1; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: .8rem; font-weight: 600; color: var(--ink); letter-spacing: .04em; text-transform: uppercase; }
.form-label .optional { font-weight: 400; color: var(--ghost); text-transform: none; letter-spacing: 0; }
.form-input, .form-select, .form-textarea {
  padding: 10px 14px; border: 1.5px solid var(--border);
  border-radius: 8px; font-size: .9rem; color: var(--ink);
  background: var(--white); transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(31,107,106,.12);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: .75rem; color: var(--ghost); }
.form-error { font-size: .78rem; color: var(--red); }

/* ─── Table ──────────────────────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; }
thead { background: var(--teal-mist); }
thead th {
  padding: 12px 16px; text-align: left;
  font-size: .75rem; font-weight: 700; letter-spacing: .06em;
  color: var(--teal); text-transform: uppercase; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--teal-mist); }
tbody td { padding: 13px 16px; font-size: .875rem; color: var(--ink); }
.td-name { font-weight: 600; }
.td-secondary { color: var(--ghost); font-size: .8rem; }

/* ─── Status badges ──────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 999px;
  font-size: .73rem; font-weight: 700; letter-spacing: .04em; white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .7; }
.badge-rascunho  { background: #f3f4f6; color: #6b7280; }
.badge-disponivel{ background: var(--green-light); color: var(--green); }
.badge-expirado  { background: var(--red-light); color: var(--red); }

/* ─── Search bar ─────────────────────────────────────────────────────────────── */
.search-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.search-input-wrap { position: relative; }
.search-input-wrap svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ghost); pointer-events: none; }
.search-input { padding: 9px 14px 9px 38px; min-width: 260px; }

/* ─── Protocol / password display ───────────────────────────────────────────── */
.credential-box {
  background: var(--teal-mist); border: 1px solid var(--teal-light);
  border-radius: 10px; padding: 18px 20px;
}
.credential-label { font-size: .7rem; font-weight: 700; letter-spacing: .1em; color: var(--teal); margin-bottom: 6px; }
.credential-value { font-family: 'JetBrains Mono', 'Courier New', monospace; font-size: 1.3rem; font-weight: 700; color: var(--ink); letter-spacing: .04em; }
.credential-copy  { margin-top: 8px; }

/* ─── File list ──────────────────────────────────────────────────────────────── */
.file-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--white);
}
.file-icon  { width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.file-pdf   { background: #fee2e2; color: var(--red); }
.file-image { background: var(--teal-light); color: var(--teal); }
.file-name  { font-size: .875rem; font-weight: 500; }
.file-size  { font-size: .75rem; color: var(--ghost); }
.file-list  { display: flex; flex-direction: column; gap: 8px; }

/* ─── Upload zone ────────────────────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border); border-radius: 10px;
  padding: 32px 24px; text-align: center; cursor: pointer;
  transition: border-color .2s, background .2s;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--teal); background: var(--teal-mist);
}
.upload-zone p { font-size: .875rem; color: var(--ghost); margin-top: 8px; }

/* ─── Login page ─────────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--ink);
}
.login-card {
  background: var(--white); border-radius: 16px;
  padding: 40px 40px 36px; width: 100%; max-width: 420px;
  box-shadow: 0 24px 48px rgba(0,0,0,.25);
}
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo .logo-name { font-size: 1.4rem; font-weight: 700; color: var(--teal); margin-top: 8px; }
.login-logo .logo-sub  { font-size: .75rem; letter-spacing: .16em; color: var(--ghost); font-weight: 600; }
.login-error {
  background: var(--red-light); color: var(--red);
  padding: 10px 14px; border-radius: 8px;
  font-size: .85rem; margin-bottom: 16px; display: none;
}

/* ─── Detail page ────────────────────────────────────────────────────────────── */
.detail-grid { display: grid; grid-template-columns: 1fr 380px; gap: 24px; align-items: start; }
.detail-section { margin-bottom: 24px; }
.detail-section:last-child { margin-bottom: 0; }
.detail-row { display: flex; gap: 4px; flex-direction: column; padding: 12px 0; border-bottom: 1px solid var(--border); }
.detail-row:last-child { border-bottom: none; }
.detail-key { font-size: .73rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ghost); }
.detail-val { font-size: .9rem; color: var(--ink); }

/* ─── Toast notification ─────────────────────────────────────────────────────── */
#toast {
  position: fixed; bottom: 28px; right: 28px; z-index: 9999;
  background: var(--ink); color: #fff;
  padding: 14px 20px; border-radius: 10px;
  font-size: .875rem; font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
  transform: translateY(80px); opacity: 0;
  transition: transform .25s, opacity .25s;
  max-width: 320px;
}
#toast.show { transform: translateY(0); opacity: 1; }
#toast.success { background: var(--green); }
#toast.error   { background: var(--red); }

/* ─── Empty state ────────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 60px 24px; }
.empty-state svg { color: var(--border); margin-bottom: 12px; }
.empty-state p   { color: var(--ghost); font-size: .875rem; }

/* ─── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { width: 200px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .sidebar { display: none; }
  .page-header { padding: 16px 20px; }
  .page-body  { padding: 20px; }
  .stats-grid { grid-template-columns: 1fr; }
}
