* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: #16213a; background: #fff; }
.auth { display: grid; grid-template-columns: 1.05fr 1fr; min-height: 100vh; }

.hero { background: linear-gradient(155deg, #1f3a68 0%, #16294d 60%, #0f1f3d 100%); color: #dfe8f7; padding: 56px; display: flex; flex-direction: column; gap: 28px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 1.1rem; }
.brand .logo { width: 36px; height: 36px; border-radius: 9px; background: rgba(255,255,255,.12); display: grid; place-items: center; }
.brand small { display: block; font-weight: 500; font-size: .72rem; color: #a9bddf; letter-spacing: .04em; text-transform: uppercase; }
.hero h1 { color: #fff; font-size: 2.3rem; line-height: 1.15; margin: 0; }
.lead { font-size: 1.05rem; color: #b8c9e6; max-width: 460px; }
.foot { margin-top: auto; font-size: .82rem; color: #8ea3c8; }

.panel { display: grid; place-items: center; padding: 40px 24px; }
.card { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 16px; }
h2 { margin: 0; font-size: 1.6rem; }
p { margin: 4px 0 0; }
.muted { color: #7a849b; }
.small { font-size: .85rem; }

form { display: flex; flex-direction: column; gap: 12px; }
label { display: flex; flex-direction: column; gap: 5px; font-size: .85rem; font-weight: 600; color: #4a5570; }
input { font: inherit; padding: 10px 12px; border: 1px solid #cfd6e3; border-radius: 8px; }
input:focus { outline: 2px solid #9cc3ff; border-color: #2b6fdb; }
button { font: inherit; font-weight: 600; padding: 10px 14px; border-radius: 8px; border: 1px solid #cfd6e3; background: #fff; cursor: pointer; }
button.primary { background: #2b5aa6; border-color: #2b5aa6; color: #fff; }
button.primary:hover { background: #1f3a68; }
button:disabled { opacity: .5; cursor: not-allowed; }

.card.wide { max-width: 640px; }
.panel a { color: #2b5aa6; font-weight: 600; }
.opt { font-weight: 400; color: #7a849b; font-size: .75rem; }
.row2, .row3 { display: grid; gap: 12px; }
.row2 > *, .row3 > * { min-width: 0; }
input { min-width: 0; }
.row2 { grid-template-columns: 1fr 1fr; }
.row3 { grid-template-columns: 1fr 1fr 1fr; }
fieldset { min-width: 0; border: 1px solid #e3e7ef; border-radius: 10px; padding: 10px 12px 12px; margin: 0; display: flex; flex-direction: column; gap: 10px; }
legend { font-size: .85rem; font-weight: 600; color: #4a5570; padding: 0 4px; }
select { width: 100%; }
.reset-link { margin-top: 8px; }
.notice { padding: 10px 14px; border-radius: 8px; background: #ecf8f0; border: 1px solid #b6e2c4; color: #14532d; font-size: .9rem; }
@media (max-width: 560px) { .row2, .row3 { grid-template-columns: 1fr; } }
.error { padding: 10px 14px; border-radius: 8px; background: #fdecea; border: 1px solid #f6c7c1; color: #7a1b12; font-size: .9rem; }
.demo { border: 1px dashed #cfd6e3; border-radius: 10px; padding: 12px 14px; background: #f8f9fc; }
.chips { display: flex; gap: 6px; margin-top: 8px; }
.chips button { border-radius: 99px; padding: 4px 12px; font-size: .8rem; font-weight: 500; }

/* ---------- Dashboard ---------- */
[hidden] { display: none !important; }
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; background: #f4f6fa; }
.sidebar { background: #1f3a68; color: #dfe8f7; padding: 18px 14px; display: flex; flex-direction: column; gap: 16px; }
.sidebar nav a { display: block; padding: 8px 10px; border-radius: 8px; color: #dfe8f7; text-decoration: none; font-weight: 500; }
.sidebar nav a.active { background: #fff; color: #1f3a68; }
.me { margin-top: auto; border-top: 1px solid rgba(255,255,255,.12); padding-top: 12px; font-size: .85rem; display: flex; flex-direction: column; gap: 2px; }
.me strong { color: #fff; }
.me span { color: #a9bddf; }
.me button { margin-top: 10px; background: transparent; color: #dfe8f7; border-color: rgba(255,255,255,.3); }
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar { background: #fff; border-bottom: 1px solid #e3e7ef; padding: 12px 28px; }
.badge { background: #1f3a68; color: #fff; border-radius: 99px; padding: 3px 10px; font-size: .75rem; font-weight: 600; }
.content { padding: 24px 28px; display: flex; flex-direction: column; gap: 16px; }
.topbar { display: flex; align-items: center; gap: 10px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
#page-blocks { display: flex; flex-direction: column; gap: 16px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.stat { background: #fff; border: 1px solid #e3e7ef; border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.stat-label { font-size: .75rem; font-weight: 600; color: #7a849b; text-transform: uppercase; letter-spacing: .03em; }
.stat-value { font-size: 1.05rem; color: #16213a; overflow-wrap: anywhere; }
.filters { display: flex; flex-wrap: wrap; gap: 12px; }
.filters label { flex-direction: row; align-items: center; gap: 8px; }
select { font: inherit; padding: 7px 10px; border: 1px solid #cfd6e3; border-radius: 8px; background: #fff; }
.table-card { background: #fff; border: 1px solid #e3e7ef; border-radius: 12px; overflow: hidden; }
.table-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 14px 16px 10px; }
.table-head h3 { margin: 0; font-size: 1rem; }
.note { margin: -4px 16px 10px; }
.empty-row { padding: 0 16px 16px; margin: 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th, td { text-align: left; padding: 9px 16px; border-top: 1px solid #eef1f6; white-space: nowrap; }
th { background: #f8f9fc; font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: #4a5570; }
tbody tr:hover { background: #f8f9fc; }
.flash { border-radius: 12px; padding: 12px 16px; display: flex; flex-direction: column; gap: 4px; border: 1px solid; }
.flash.ok { background: #ecf8f0; border-color: #b6e2c4; color: #14532d; }
.flash.err { background: #fdecea; border-color: #f6c7c1; color: #7a1b12; }
code.sql { display: block; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .8rem; white-space: pre-wrap; overflow-wrap: anywhere; background: rgba(0,0,0,.05); border-radius: 8px; padding: 8px 10px; margin-top: 4px; }
code.sql.query { margin: 0 16px 12px; background: #f4f6fa; color: #4a5570; }
.row-action { padding: 5px 12px; font-size: .8rem; background: #2b5aa6; border-color: #2b5aa6; color: #fff; }
.row-action:hover { background: #1f3a68; }
.row-action.danger { background: #fff; color: #b42318; border-color: #f0b4ad; }
.row-action.danger:hover { background: #fdecea; }
.row-action.secondary { background: #fff; color: #4a5570; border-color: #cfd6e3; }
.row-action.secondary:hover { background: #f4f6fa; }
.form-card { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 14px; }
.form-card h3 { margin: 0; font-size: 1rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.form-grid select, .form-grid input { width: 100%; }
.form-card button.primary { align-self: flex-start; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .content { padding: 16px; }
  .auth { grid-template-columns: 1fr; }
  .hero { padding: 32px 20px; }
  .foot { display: none; }
}
