/* ============================================================
   INFORMED PACS — Design System
   Paleta: Azul institucional Informed + Branco + Cinzas suaves
   ============================================================ */
:root {
  --informed-blue: #0b5cab;
  --informed-blue-dark: #08447f;
  --informed-blue-light: #e7f0fb;
  --informed-blue-50: #f3f8fd;
  --accent: #f59e0b;
  --white: #ffffff;
  --gray-50: #f7f9fb;
  --gray-100: #eef2f5;
  --gray-200: #e2e8ee;
  --gray-300: #cbd5dd;
  --gray-400: #94a3b0;
  --gray-500: #64748b;
  --gray-700: #334155;
  --gray-800: #1f2937;
  --gray-900: #0f172a;
  --danger: #dc2626;
  --warning: #f59e0b;
  --info: #0ea5e9;
  --success: #16a34a;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);

  --sidebar-w: 240px;
  --header-h: 64px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--gray-800);
  background: var(--gray-50);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--informed-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============ LOGIN ============ */
.login-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--white);
}
.login-hero {
  background: linear-gradient(135deg, var(--informed-blue) 0%, var(--informed-blue-dark) 100%);
  color: #fff;
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.login-hero::after {
  content: ''; position: absolute; right: -120px; bottom: -120px;
  width: 420px; height: 420px; border-radius: 50%;
  background: rgba(255,255,255,0.08);
}
.login-hero h1 { font-size: 36px; margin: 0 0 12px; font-weight: 800; }
.login-hero p { font-size: 16px; opacity: .92; max-width: 420px; line-height: 1.6; }
.login-hero .features { display: grid; gap: 14px; margin-top: 32px; position: relative; z-index: 1; }
.login-hero .feat { display: flex; align-items: center; gap: 12px; font-size: 15px; }
.login-hero .feat span { background: rgba(255,255,255,.18); width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; }

.login-form {
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}
.login-form .brand { display: flex; align-items: center; gap: 12px; margin-bottom: 32px; }
.login-form h2 { margin: 0 0 8px; font-size: 26px; color: var(--gray-900); }
.login-form .sub { color: var(--gray-500); margin-bottom: 28px; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 500; margin-bottom: 6px; font-size: 13px; color: var(--gray-700); }
.input, select, textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--white);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--informed-blue);
  box-shadow: 0 0 0 3px var(--informed-blue-light);
}
textarea { resize: vertical; min-height: 100px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
  background: var(--white);
  color: var(--gray-700);
  border-color: var(--gray-200);
}
.btn:hover { background: var(--gray-50); }
.btn-primary { background: var(--informed-blue); color: #fff; border-color: var(--informed-blue); }
.btn-primary:hover { background: var(--informed-blue-dark); border-color: var(--informed-blue-dark); }
.btn-accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-accent:hover { filter: brightness(.95); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--gray-600); }
.btn-block { width: 100%; justify-content: center; padding: 12px; }
.btn-sm { padding: 6px 10px; font-size: 12px; }

/* ============ APP SHELL ============ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--header-h) 1fr;
  grid-template-areas: 'sidebar header' 'sidebar main';
  min-height: 100vh;
}
.sidebar {
  grid-area: sidebar;
  background: var(--white);
  border-right: 1px solid var(--gray-200);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--gray-100);
}
.brand-logo {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--informed-blue), var(--informed-blue-dark));
  color: #fff; border-radius: 10px;
  display: grid; place-items: center;
  font-weight: 800; font-size: 16px;
  box-shadow: var(--shadow-sm);
}
.brand-name { font-weight: 800; color: var(--gray-900); font-size: 15px; letter-spacing: .2px; }
.brand-sub { font-size: 11px; color: var(--gray-500); text-transform: uppercase; letter-spacing: 1px; }

.nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; margin: 2px 0;
  border-radius: var(--radius-sm);
  color: var(--gray-600);
  font-weight: 500;
  text-decoration: none;
  transition: all .15s;
}
.nav a:hover { background: var(--gray-50); color: var(--gray-900); }
.nav a.active {
  background: var(--informed-blue-light);
  color: var(--informed-blue-dark);
}
.nav a .ic { width: 18px; height: 18px; flex-shrink: 0; }
.nav-section { padding: 14px 14px 6px; font-size: 11px; color: var(--gray-400); text-transform: uppercase; letter-spacing: 1px; }

.sidebar-foot {
  padding: 14px 18px;
  border-top: 1px solid var(--gray-100);
  font-size: 12px; color: var(--gray-500);
}

.header {
  grid-area: header;
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky; top: 0; z-index: 10;
}
.header h1 { font-size: 18px; margin: 0; font-weight: 700; color: var(--gray-900); }
.header .spacer { flex: 1; }
.header .search {
  position: relative; max-width: 360px; flex: 1;
}
.header .search input {
  width: 100%;
  padding: 9px 12px 9px 36px;
  border: 1px solid var(--gray-200);
  background: var(--gray-50);
  border-radius: 999px; font-size: 13px;
}
.header .search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--gray-400); }

.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 10px 4px 4px;
  background: var(--gray-50);
  border-radius: 999px;
  cursor: pointer;
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--informed-blue), var(--informed-blue-dark));
  color: #fff; display: grid; place-items: center;
  font-weight: 700; font-size: 13px;
}
.user-chip .name { font-size: 13px; font-weight: 600; }
.user-chip .role { font-size: 11px; color: var(--gray-500); }

.main {
  grid-area: main;
  padding: 24px;
  overflow-x: hidden;
}

/* ============ CARDS / GRIDS ============ */
.page-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; gap: 16px; flex-wrap: wrap;
}
.page-head h2 { margin: 0; font-size: 22px; font-weight: 700; color: var(--gray-900); }
.page-head .sub { font-size: 13px; color: var(--gray-500); margin-top: 4px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-100);
  display: flex; gap: 16px; align-items: center;
}
.stat-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--informed-blue-light); color: var(--informed-blue-dark);
}
.stat-icon.blue { background: #e0f2fe; color: #0284c7; }
.stat-icon.orange { background: #fef3e7; color: var(--accent); }
.stat-icon.purple { background: #f3e8ff; color: #7c3aed; }
.stat-card .v { font-size: 24px; font-weight: 800; color: var(--gray-900); }
.stat-card .l { font-size: 12px; color: var(--gray-500); text-transform: uppercase; letter-spacing: .5px; }

.card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--gray-100);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--gray-100); gap: 12px;
}
.card-head h3 { margin: 0; font-size: 15px; font-weight: 700; color: var(--gray-900); }
.card-body { padding: 20px; }
.card-body.p0 { padding: 0; }

.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
@media (max-width: 1000px) { .grid-2 { grid-template-columns: 1fr; } }

/* ============ TABLES ============ */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table thead th {
  text-align: left; padding: 12px 16px;
  background: var(--gray-50);
  color: var(--gray-500); font-weight: 600;
  text-transform: uppercase; font-size: 11px; letter-spacing: .5px;
  border-bottom: 1px solid var(--gray-100);
  white-space: nowrap;
}
.table tbody td { padding: 12px 16px; border-bottom: 1px solid var(--gray-100); color: var(--gray-700); }
.table tbody tr:hover { background: var(--gray-50); }
.table .actions { display: flex; gap: 6px; justify-content: flex-end; }

.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
  background: var(--gray-100); color: var(--gray-600);
  text-transform: uppercase; letter-spacing: .3px;
}
.badge.green { background: var(--informed-blue-light); color: var(--informed-blue-dark); }
.badge.blue { background: #e0f2fe; color: #0369a1; }
.badge.orange { background: #fef3e7; color: var(--accent); }
.badge.purple { background: #f3e8ff; color: #7c3aed; }
.badge.gray { background: var(--gray-100); color: var(--gray-600); }

/* ============ FILTERS ============ */
.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px; align-items: end;
}

/* ============ MODAL ============ */
.modal-back {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .55);
  display: none; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
}
.modal-back.open { display: flex; }
.modal {
  background: var(--white); border-radius: var(--radius);
  width: 100%; max-width: 600px; max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.modal.lg { max-width: 900px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--gray-100);
}
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot {
  padding: 14px 20px; border-top: 1px solid var(--gray-100);
  display: flex; gap: 8px; justify-content: flex-end;
}
.close-x {
  background: none; border: none; cursor: pointer; padding: 4px;
  color: var(--gray-500); font-size: 20px;
}

/* ============ TOAST ============ */
.toast-wrap { position: fixed; top: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--white); border-left: 4px solid var(--informed-blue);
  padding: 12px 18px; border-radius: 8px;
  box-shadow: var(--shadow-lg);
  min-width: 280px; font-size: 13px;
  animation: slideIn .25s ease;
}
.toast.error { border-color: var(--danger); }
.toast.warn { border-color: var(--warning); }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } }

/* ============ EMPTY STATES ============ */
.empty {
  text-align: center; padding: 60px 20px; color: var(--gray-500);
}
.empty svg { color: var(--gray-300); margin-bottom: 12px; }
.empty h4 { margin: 8px 0 4px; color: var(--gray-700); }

/* ============ LAUDO ============ */
.laudo-paper {
  background: #fff; padding: 40px;
  max-width: 800px; margin: 0 auto;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-family: 'Georgia', serif;
  color: var(--gray-800);
}
.laudo-head { display: flex; gap: 20px; align-items: center; border-bottom: 3px solid var(--informed-blue); padding-bottom: 16px; }
.laudo-head .logo {
  width: 60px; height: 60px; border-radius: 10px;
  background: var(--informed-blue); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 22px;
  font-family: var(--font);
}
.laudo-head h1 { margin: 0; color: var(--informed-blue-dark); font-size: 22px; font-family: var(--font); }
.laudo-head .info { font-size: 12px; color: var(--gray-500); font-family: var(--font); }

.laudo-section { margin-top: 24px; }
.laudo-section h3 {
  font-size: 13px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--informed-blue-dark); border-bottom: 1px solid var(--gray-200);
  padding-bottom: 6px; margin: 0 0 12px; font-family: var(--font);
}
.laudo-info-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 24px; font-family: var(--font); font-size: 13px; }
.laudo-info-grid div span { color: var(--gray-500); margin-right: 6px; }
.laudo-content { font-size: 14px; line-height: 1.7; white-space: pre-wrap; }
.laudo-thumb { max-width: 100%; max-height: 240px; border-radius: 6px; border: 1px solid var(--gray-200); }
.laudo-sign {
  margin-top: 50px; padding-top: 10px;
  border-top: 1px solid var(--gray-400);
  text-align: center; font-family: var(--font);
}
.laudo-foot {
  margin-top: 30px; padding-top: 14px;
  border-top: 1px solid var(--gray-200);
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; color: var(--gray-500); font-family: var(--font);
}

/* ============ MOBILE ============ */
.menu-toggle { display: none; background: none; border: none; cursor: pointer; padding: 6px; }
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; grid-template-areas: 'header' 'main'; }
  .sidebar {
    position: fixed; left: -100%; top: 0; height: 100vh; width: 260px;
    transition: left .25s; z-index: 50; box-shadow: var(--shadow-lg);
  }
  .sidebar.open { left: 0; }
  .menu-toggle { display: inline-flex; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-hero { display: none; }
}
@media (max-width: 600px) {
  .grid-2 { grid-template-columns: 1fr; }
  .header .search { display: none; }
  .main { padding: 16px; }
  .user-chip .name, .user-chip .role { display: none; }
}

/* Print (laudo) */
@media print {
  .sidebar, .header, .page-actions, .no-print { display: none !important; }
  .app { display: block; }
  .main { padding: 0; }
  .laudo-paper { box-shadow: none; border: none; }
}
