/* ============================================================================
   LINE Monitor — shared design system (app.css)
   One place for palette, typography, and components so every page is consistent.
   ============================================================================ */
:root {
    --brand: #16a34a;          /* primary action (LINE green) */
    --brand-600: #15803d;
    --brand-050: #ecfdf3;
    --accent: #6366f1;         /* active / links (indigo) */
    --bg: #eef1f6;             /* app background */
    --surface: #ffffff;        /* cards / panels */
    --surface-2: #f7f9fc;      /* subtle fills, table head */
    --ink: #1f2733;            /* primary text */
    --ink-2: #5b6472;          /* secondary text */
    --ink-3: #98a1b0;          /* muted */
    --line: #e6e9f0;           /* borders */
    --rail: #171e2e;           /* dark sidebar */
    --rail-2: #232c42;         /* sidebar hover/active */
    --rail-ink: #c3cad9;       /* sidebar text */
    --ok: #16a34a; --ok-bg: #e7f7ee;
    --warn: #c2740a; --warn-bg: #fdf1e1;
    --danger: #dc2626; --danger-bg: #fdecec;
    --pink: #b3187a; --pink-bg: #fce7f3;
    --info: #2563eb; --info-bg: #e8f0fe;
    --radius: 14px; --radius-sm: 9px;
    --shadow: 0 1px 2px rgba(16,24,40,.04), 0 8px 24px rgba(16,24,40,.06);
    --shadow-lg: 0 12px 40px rgba(16,24,40,.16);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans Thai', sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); min-height: 100vh;
    -webkit-font-smoothing: antialiased; font-size: 14px; line-height: 1.5; }
a { color: inherit; text-decoration: none; }

/* --- app shell: dark rail + light content ---------------------------------- */
.app { display: flex; min-height: 100vh; }
.rail { width: 248px; flex-shrink: 0; background: var(--rail); color: var(--rail-ink);
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.rail .brand { display: flex; align-items: center; gap: 10px; padding: 20px 22px; font-weight: 700;
    font-size: 1.05em; color: #fff; letter-spacing: .01em; }
.rail .brand .dot { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, var(--brand), #22c55e);
    display: flex; align-items: center; justify-content: center; font-size: 1em; box-shadow: 0 4px 12px rgba(22,163,74,.4); }
.rail nav { padding: 8px 12px; display: flex; flex-direction: column; gap: 2px; }
.rail nav a { display: flex; align-items: center; gap: 11px; padding: 10px 13px; border-radius: 10px;
    color: var(--rail-ink); font-size: .95em; font-weight: 500; transition: background .15s, color .15s; }
.rail nav a .ic { width: 20px; text-align: center; opacity: .9; }
.rail nav a:hover { background: var(--rail-2); color: #fff; }
.rail nav a.active { background: var(--rail-2); color: #fff; box-shadow: inset 3px 0 0 var(--brand); }
.rail .spacer { flex: 1; }
.rail nav a.logout { color: #fca5a5; }
.rail nav a.logout:hover { background: #3b1d20; color: #fecaca; }
.rail .who { padding: 14px 20px; border-top: 1px solid rgba(255,255,255,.07); font-size: .82em; color: #8b93a4; }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; max-height: 100vh; overflow-y: auto; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 20px 30px; position: sticky; top: 0; background: rgba(238,241,246,.85);
    backdrop-filter: saturate(1.5) blur(8px); z-index: 20; border-bottom: 1px solid var(--line); }
.topbar h1 { font-size: 1.3em; font-weight: 700; color: var(--ink); letter-spacing: -.01em; }
.topbar .sub { color: var(--ink-2); font-size: .85em; margin-top: 2px; font-weight: 400; }
.topbar .actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page { padding: 24px 30px 40px; }

/* --- cards / panels -------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 20px 22px; }
.grid { display: grid; gap: 16px; }

/* stat tiles */
.stats { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat .n { font-size: 1.9em; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; color: var(--ink); }
.stat .l { font-size: .78em; color: var(--ink-2); margin-top: 4px; font-weight: 500; }
.stat.ok .n { color: var(--ok); } .stat.warn .n { color: var(--warn); }
.stat.danger .n { color: var(--danger); } .stat.pink .n { color: var(--pink); } .stat.info .n { color: var(--info); }

/* --- buttons --------------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 9px 16px; border: 1px solid transparent;
    border-radius: var(--radius-sm); background: var(--brand); color: #fff; font-size: .9em; font-weight: 600;
    font-family: inherit; cursor: pointer; transition: background .15s, box-shadow .15s, transform .05s; white-space: nowrap; }
.btn:hover { background: var(--brand-600); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--ink-2); border-color: var(--line); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.warn { background: var(--warn); } .btn.warn:hover { background: #a4620a; }
.btn.danger { background: var(--danger); } .btn.danger:hover { background: #b91c1c; }
.btn.sm { padding: 6px 11px; font-size: .82em; }

/* --- inputs ---------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: .76em; font-weight: 600; color: var(--ink-2); }
input, select, textarea { font-family: inherit; font-size: .92em; color: var(--ink); background: var(--surface);
    border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 9px 11px; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99,102,241,.15); }

/* --- badges ---------------------------------------------------------------- */
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px;
    font-size: .78em; font-weight: 600; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.warn, .tag.drop { background: var(--warn-bg); color: var(--warn); }
.tag.danger, .tag.err, .tag.http { background: var(--danger-bg); color: var(--danger); }
.tag.corr, .tag.pink { background: var(--pink-bg); color: var(--pink); }
.tag.info, .tag.official { background: var(--info-bg); color: var(--info); }
.dot-ind { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot-ind.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(22,163,74,.15); }
.dot-ind.off { background: var(--danger); box-shadow: 0 0 0 3px rgba(220,38,38,.12); }

/* --- tables ---------------------------------------------------------------- */
.tbl { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); box-shadow: var(--shadow); }
.tbl .scroll { overflow: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .88em; }
table.data th, table.data td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); }
table.data th { color: var(--ink-2); font-weight: 600; font-size: .82em; text-transform: none;
    background: var(--surface-2); position: sticky; top: 0; z-index: 1; }
table.data tbody tr:last-child td { border-bottom: none; }
table.data tr.clickable { cursor: pointer; } table.data tr.clickable:hover { background: var(--surface-2); }
.muted { color: var(--ink-3); }
.empty { color: var(--ink-3); text-align: center; padding: 34px; }
.updated { color: var(--ink-3); font-size: .8em; }

/* banners */
.banner { border-radius: var(--radius); padding: 13px 18px; font-size: .92em; border: 1px solid transparent; }
.banner.good { background: var(--ok-bg); color: var(--brand-600); border-color: #bbf0cf; }
.banner.bad { background: var(--danger-bg); color: #b91c1c; border-color: #f6c9c9; }
.banner.info { background: var(--info-bg); color: #1d4ed8; border-color: #cddffb; }

/* section heading */
.h-sec { font-size: 1.02em; font-weight: 700; color: var(--ink); margin: 6px 0 12px; display: flex; align-items: center; gap: 8px; }

/* json detail */
.jgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 820px) { .jgrid { grid-template-columns: 1fr; } }
.jgrid .jl { font-size: .76em; color: var(--ink-2); font-weight: 600; margin-bottom: 5px; }
pre.json { white-space: pre-wrap; word-break: break-word; font-size: .82em;
    font-family: 'SF Mono', ui-monospace, 'Cascadia Code', Menlo, Consolas, monospace;
    color: var(--ink); background: #fbfcfe; border: 1px solid var(--line); border-radius: var(--radius-sm);
    padding: 12px; max-height: 300px; overflow: auto; }
.tok-key { color: #7c3aed; } .tok-str { color: #15803d; } .tok-num { color: #1d4ed8; }
.tok-bool { color: #c2740a; font-weight: 600; } .tok-null { color: var(--ink-3); font-style: italic; }

/* --- modal ----------------------------------------------------------------- */
.overlay { position: fixed; inset: 0; background: rgba(15,23,42,.5); backdrop-filter: blur(2px);
    display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 1000; }
.modal { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); width: 100%;
    max-width: 560px; max-height: 88vh; overflow-y: auto; padding: 26px 28px; }
.modal h2 { font-size: 1.25em; font-weight: 700; margin-bottom: 4px; }
.modal .sec { border-top: 1px solid var(--line); padding: 13px 0; }
.modal .sec h3 { font-size: .82em; color: var(--ink-2); font-weight: 600; margin-bottom: 6px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* --- auth (login / centered) ----------------------------------------------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
    background: radial-gradient(1100px 520px at 50% -10%, #e3ebf7, transparent), var(--bg); }
.auth-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-lg);
    width: 100%; max-width: 400px; padding: 32px 30px; }
.auth-card .logo { display: flex; align-items: center; gap: 11px; justify-content: center; margin-bottom: 6px; }
.auth-card .logo .dot { width: 40px; height: 40px; border-radius: 12px; background: linear-gradient(135deg, var(--brand), #22c55e);
    display: flex; align-items: center; justify-content: center; font-size: 1.3em; box-shadow: 0 6px 18px rgba(22,163,74,.4); }
.auth-card h2 { text-align: center; font-size: 1.3em; font-weight: 700; margin-bottom: 22px; }
.auth-card .field { margin-bottom: 14px; }
.auth-card .btn { width: 100%; justify-content: center; padding: 11px; font-size: .98em; }
.auth-card .error { color: var(--danger); text-align: center; margin-top: 14px; font-size: .9em; min-height: 1em; }

/* --- responsive ------------------------------------------------------------ */
@media (max-width: 820px) {
    .app { flex-direction: column; }
    .rail { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; }
    .rail nav { flex-direction: row; flex-wrap: wrap; padding: 6px 10px; }
    .rail .spacer, .rail .who { display: none; }
    .content { max-height: none; }
    .topbar, .page { padding-left: 18px; padding-right: 18px; }
}
/* button variants used by markup with hyphenated classes */
.btn-danger { background: var(--danger); color: #fff; } .btn-danger:hover { background: #b91c1c; }
.btn-secondary { background: transparent; color: var(--ink-2); border-color: var(--line); } .btn-secondary:hover { background: var(--surface-2); color: var(--ink); }

/* inline spinner */
.loading { width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.55); border-top-color: #fff; border-radius: 50%; display: inline-block; animation: spin .7s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* toast messages (top-right) */
#messages { position: fixed; top: 16px; right: 16px; z-index: 1100; display: flex; flex-direction: column; gap: 8px; }
.message { padding: 12px 16px; border-radius: var(--radius-sm); font-size: .9em; font-weight: 500; box-shadow: var(--shadow); border: 1px solid transparent; background: #fff; }
.message.success { background: var(--ok-bg); color: var(--brand-600); border-color: #bbf0cf; }
.message.error { background: var(--danger-bg); color: #b91c1c; border-color: #f6c9c9; }

[hidden] { display: none !important; }
.hidden { display: none !important; }
