:root {
    --navy-950: #03112b;
    --navy-900: #071a3d;
    --navy-800: #0b2858;
    --navy-700: #123b78;
    --blue-500: #2d6cdf;
    --silver-500: #98a5b8;
    --silver-200: #dfe5ee;
    --surface: #ffffff;
    --surface-2: #f4f7fb;
    --text: #17243a;
    --muted: #66758b;
    --border: #dbe3ed;
    --success: #087f5b;
    --warning: #b86200;
    --danger: #b42318;
    --shadow: 0 18px 45px rgba(7, 26, 61, .10);
    --radius: 16px;
    color-scheme: light;
}

html[data-theme="dark"] {
    --surface: #0d1b32;
    --surface-2: #071426;
    --text: #edf3fb;
    --muted: #9aacbf;
    --border: #263951;
    --shadow: 0 18px 45px rgba(0, 0, 0, .28);
    color-scheme: dark;
}

* { box-sizing: border-box; }
html { min-height: 100%; scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--text); background: var(--surface-2); }
a { color: var(--navy-700); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.skip-link { position: fixed; left: 16px; top: -100px; z-index: 9999; background: #fff; color: #000; padding: 12px; }
.skip-link:focus { top: 16px; }

.app-body { display: flex; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 50; width: 274px; display: flex; flex-direction: column; padding: 20px 16px; color: #fff; background: linear-gradient(180deg, var(--navy-950), var(--navy-800)); border-right: 1px solid rgba(255,255,255,.09); }
.brand { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 4px 9px 20px; color: #fff; text-decoration: none; }
.brand img { filter: drop-shadow(0 8px 18px rgba(0,0,0,.25)); }
.brand span { display: flex; align-items: baseline; font-family: Georgia, serif; font-size: 24px; letter-spacing: .2px; }
.brand em { color: #c8d0dc; font-style: normal; font-weight: 400; }
.main-nav { display: flex; flex: 1; flex-direction: column; gap: 5px; overflow-y: auto; }
.main-nav a { display: flex; align-items: center; gap: 12px; padding: 11px 13px; color: #dbe7f7; border: 1px solid transparent; border-radius: 11px; text-decoration: none; font-size: 14px; transition: .18s ease; }
.main-nav a span { display: grid; width: 24px; place-items: center; font-size: 18px; color: #aebdce; }
.main-nav a:hover, .main-nav a.active { color: #fff; background: rgba(255,255,255,.11); border-color: rgba(255,255,255,.10); transform: translateX(2px); }
.nav-section { margin: 17px 12px 6px; color: #8fa2bb; font-size: 10px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 15px 10px 5px; border-top: 1px solid rgba(255,255,255,.12); }
.sidebar-user .avatar { display: grid; width: 38px; height: 38px; flex: 0 0 38px; place-items: center; border-radius: 12px; background: linear-gradient(145deg, #eef2f7, #8d9aab); color: var(--navy-900); font-weight: 900; }
.sidebar-user strong, .sidebar-user small { display: block; max-width: 175px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user strong { font-size: 13px; }
.sidebar-user small { margin-top: 2px; color: #9cacc0; font-size: 10px; }

.app-shell { width: calc(100% - 274px); min-height: 100vh; margin-left: 274px; }
.topbar { position: sticky; top: 0; z-index: 40; display: flex; align-items: center; justify-content: space-between; min-height: 86px; padding: 14px clamp(18px, 3vw, 42px); background: color-mix(in srgb, var(--surface) 90%, transparent); border-bottom: 1px solid var(--border); backdrop-filter: blur(16px); }
.topbar h1 { margin: 3px 0 0; font-family: Georgia, serif; font-size: clamp(22px, 2vw, 30px); font-weight: 600; }
.eyebrow { color: var(--blue-500); font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.topbar-tools { display: flex; align-items: center; gap: 8px; }
.clock-card { min-width: 122px; padding: 8px 12px; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; cursor: pointer; text-align: right; }
.clock-card span, .clock-card strong { display: block; }
.clock-card span { color: var(--muted); font-size: 10px; }
.clock-card strong { margin-top: 1px; font-variant-numeric: tabular-nums; font-size: 15px; }
.icon-button { display: grid; width: 42px; height: 42px; place-items: center; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 11px; cursor: pointer; }
.icon-button:hover { border-color: var(--blue-500); }
.inline-form { display: inline; }
.content { width: min(1480px, 100%); margin: 0 auto; padding: clamp(22px, 3vw, 44px); }
.app-footer { padding: 20px 42px 35px; color: var(--muted); font-size: 12px; text-align: center; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card { padding: clamp(18px, 2vw, 26px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 1px 0 rgba(7,26,61,.02); }
.card-elevated { box-shadow: var(--shadow); }
.card h2, .card h3 { margin-top: 0; }
.stat-card { position: relative; overflow: hidden; }
.stat-card::after { position: absolute; right: -25px; bottom: -35px; width: 110px; height: 110px; content: ""; border-radius: 50%; background: color-mix(in srgb, var(--blue-500) 8%, transparent); }
.stat-card .stat-label { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.stat-card .stat-value { display: block; margin-top: 9px; font-family: Georgia, serif; font-size: 34px; }
.stat-card .stat-note { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; }
.section-header { display: flex; align-items: end; justify-content: space-between; gap: 15px; margin: 30px 0 14px; }
.section-header h2 { margin: 0; font-family: Georgia, serif; font-size: 22px; }
.section-header p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 9px 15px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; cursor: pointer; text-decoration: none; font-weight: 700; font-size: 13px; }
.button:hover { border-color: var(--blue-500); transform: translateY(-1px); }
.button-primary { color: #fff; background: linear-gradient(135deg, var(--navy-800), var(--blue-500)); border-color: transparent; }
.button-danger { color: #fff; background: var(--danger); border-color: var(--danger); }
.button-small { min-height: 32px; padding: 6px 10px; font-size: 11px; }
.button[disabled], .disabled { opacity: .55; cursor: not-allowed; transform: none; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 7px; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: 12px; font-weight: 800; }
input, select, textarea { width: 100%; min-height: 43px; padding: 10px 12px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; outline: none; }
textarea { min-height: 130px; resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus { border-color: var(--blue-500); box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue-500) 14%, transparent); }
.hint { color: var(--muted); font-size: 11px; line-height: 1.5; }
.checkbox { display: flex; align-items: flex-start; gap: 9px; }
.checkbox input { width: 18px; min-height: 18px; margin-top: 2px; }
.checkbox label { font-weight: 500; line-height: 1.5; }
.filters { display: grid; grid-template-columns: repeat(5, minmax(120px, 1fr)); gap: 10px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { padding: 13px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; font-size: 13px; }
th { color: var(--muted); background: var(--surface-2); font-size: 10px; letter-spacing: .06em; text-transform: uppercase; }
tbody tr:hover { background: color-mix(in srgb, var(--blue-500) 3%, var(--surface)); }
.badge { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: 10px; font-weight: 800; }
.badge-success { color: var(--success); background: color-mix(in srgb, var(--success) 9%, var(--surface)); }
.badge-warning { color: var(--warning); background: color-mix(in srgb, var(--warning) 9%, var(--surface)); }
.badge-danger { color: var(--danger); background: color-mix(in srgb, var(--danger) 9%, var(--surface)); }
.muted { color: var(--muted); }
.empty-state { padding: 45px 20px; color: var(--muted); text-align: center; }
.alert { margin-bottom: 16px; padding: 13px 15px; border: 1px solid; border-radius: 11px; font-size: 13px; }
.alert-success { color: var(--success); background: color-mix(in srgb, var(--success) 7%, var(--surface)); border-color: color-mix(in srgb, var(--success) 25%, var(--border)); }
.alert-error { color: var(--danger); background: color-mix(in srgb, var(--danger) 7%, var(--surface)); border-color: color-mix(in srgb, var(--danger) 25%, var(--border)); }
.alert-warning { color: var(--warning); background: color-mix(in srgb, var(--warning) 7%, var(--surface)); border-color: color-mix(in srgb, var(--warning) 25%, var(--border)); }

.public-page { display: grid; min-height: 100vh; grid-template-rows: 1fr auto; background: radial-gradient(circle at 12% 18%, #173f7b 0, transparent 30%), linear-gradient(135deg, #020b1d, #071a3d 55%, #123b78); color: #fff; }
.public-main { display: grid; place-items: center; padding: 45px 20px 100px; }
.login-layout { display: grid; width: min(980px, 100%); grid-template-columns: 1.15fr .85fr; overflow: hidden; background: rgba(255,255,255,.98); border: 1px solid rgba(255,255,255,.3); border-radius: 28px; box-shadow: 0 35px 100px rgba(0,0,0,.35); color: #17243a; }
.login-brand { display: flex; flex-direction: column; justify-content: center; padding: clamp(35px, 6vw, 72px); background: linear-gradient(150deg, #f7f9fc, #e6ebf2); }
.login-brand img { width: 112px; filter: drop-shadow(0 18px 28px rgba(7,26,61,.2)); }
.login-brand h1 { margin: 24px 0 5px; font-family: Georgia, serif; font-size: clamp(34px, 5vw, 54px); color: var(--navy-900); }
.login-brand h1 span { color: #7f8b9a; font-weight: 400; }
.login-brand p { max-width: 450px; color: #5d6b7f; line-height: 1.7; }
.login-panel { padding: clamp(30px, 5vw, 55px); background: #fff; }
.login-panel h2 { margin: 5px 0 8px; font-family: Georgia, serif; font-size: 30px; }
.login-panel > p { margin: 0 0 25px; color: #64748b; font-size: 13px; }
.login-panel .form-group { margin-bottom: 15px; }
.login-panel input { color: #17243a; background: #f8fafc; border-color: #d9e1eb; }
.login-panel .button { width: 100%; margin-top: 8px; }
.access-link { display: block; margin-top: 20px; color: var(--navy-700); text-align: center; font-size: 13px; font-weight: 800; }
.public-footer { position: relative; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 10px 22px; padding: 18px 25px; color: #b5c3d5; background: rgba(1, 8, 23, .65); border-top: 1px solid rgba(255,255,255,.1); font-size: 11px; }
.public-footer a { color: #dce7f5; }
.public-card { width: min(820px, 100%); padding: clamp(25px, 5vw, 48px); color: #17243a; background: rgba(255,255,255,.98); border-radius: 24px; box-shadow: var(--shadow); }
.public-card h1 { font-family: Georgia, serif; color: var(--navy-900); }

.time-dialog { width: min(480px, calc(100% - 30px)); padding: 28px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow); }
.time-dialog::backdrop { background: rgba(2, 8, 23, .6); backdrop-filter: blur(4px); }
.dialog-close { position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; border: 0; border-radius: 50%; cursor: pointer; }
.timer-tabs, .timer-controls { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; }
.timer-tabs button { padding: 8px 11px; color: var(--muted); background: transparent; border: 0; border-bottom: 2px solid transparent; cursor: pointer; }
.timer-tabs button.active { color: var(--blue-500); border-color: var(--blue-500); }
.timer-display { margin: 30px 0; font-size: clamp(58px, 15vw, 82px); font-weight: 300; font-variant-numeric: tabular-nums; text-align: center; }
.command-trigger { position: fixed; right: 22px; bottom: 22px; z-index: 45; width: 52px; height: 52px; color: #fff; background: linear-gradient(145deg, var(--navy-800), var(--blue-500)); border: 0; border-radius: 16px; box-shadow: var(--shadow); cursor: pointer; font-size: 24px; }
.mobile-only { display: none; }

.notebook-layout { display: grid; grid-template-columns: minmax(0, 1fr) 285px; gap: 18px; }
.editor-toolbar { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.editor-toolbar button { min-width: 34px; height: 32px; border: 1px solid var(--border); background: var(--surface-2); border-radius: 7px; cursor: pointer; }
.notebook-editor { min-height: 540px; font-family: "SFMono-Regular", Consolas, monospace; line-height: 1.7; }
.legend-list { display: grid; grid-template-columns: 1fr auto; gap: 7px 12px; margin: 0; font-size: 12px; }
.legend-list dt { color: var(--muted); }
.legend-list dd { margin: 0; font-family: monospace; font-weight: 900; }
.notebook-preview { padding: 28px; background: #fff; color: #17243a; border: 1px solid #dbe3ed; border-radius: 14px; }
.notebook-preview h1, .notebook-preview h2, .notebook-preview h3, .notebook-preview h4, .notebook-preview h5, .notebook-preview h6 { margin: 1.2em 0 .55em; font-family: Georgia, serif; text-transform: uppercase; text-align: left; }
.notebook-chapter { font-size: 24px; font-weight: 800; }
.notebook-subchapter { font-size: 22px; font-weight: 800; }
.notebook-section { font-size: 20px; font-weight: 800; }
.notebook-subsection { font-size: 18px; font-weight: 800; }
.notebook-item { font-size: 16px; font-weight: 800; }
.notebook-subitem { font-size: 14px; font-weight: 800; }
.notebook-paragraph { margin: .7em 0; font-size: 12pt; line-height: 1.7; text-align: justify; }
.highlight-yellow { background: #fff2a8; }
.highlight-green { background: #bcecc8; }
.highlight-blue { background: #bddcff; }
.highlight-red { background: #ffc2c2; }
.highlight-orange { background: #ffd4a3; }
.highlight-pink { background: #ffc8e7; }
.highlight-prata { background: #e5e9ef; }

@media (max-width: 1050px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .notebook-layout { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
    .sidebar { transform: translateX(-100%); transition: transform .22s ease; }
    .sidebar.open { transform: translateX(0); box-shadow: 20px 0 60px rgba(0,0,0,.35); }
    .app-shell { width: 100%; margin-left: 0; }
    .mobile-only { display: grid; }
    .login-layout { grid-template-columns: 1fr; }
    .login-brand { display: none; }
    .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
    .content { padding: 18px 14px 35px; }
    .topbar { min-height: 72px; padding: 10px 14px; }
    .topbar .eyebrow { display: none; }
    .topbar h1 { font-size: 19px; }
    .clock-card { min-width: 93px; }
    .clock-card span { display: none; }
    .grid-2, .grid-4, .form-grid, .filters { grid-template-columns: 1fr; }
    .form-group.full { grid-column: auto; }
    .public-main { padding: 25px 12px 75px; }
    .login-panel { padding: 28px 22px; }
}
@media print {
    .sidebar, .topbar, .app-footer, .command-trigger, .actions, .no-print { display: none !important; }
    .app-shell { width: 100%; margin: 0; }
    .content { max-width: none; padding: 0; }
    .card, .table-wrap { border: 0; box-shadow: none; }
}
