:root {
  --bg1: #eaf1ff; --bg2: #f6f8ff; --glass: rgba(255,255,255,.62); --glass-b: rgba(255,255,255,.85);
  --text: #0f1a33; --muted: #6b7690; --line: rgba(15,26,51,.08);
  --blue: #2f6bff; --blue2: #7aa2ff; --green: #16a36a; --amber: #d98a00; --red: #e0453a; --violet: #7a5cff;
  --shadow: 0 10px 40px rgba(47,107,255,.10), 0 2px 8px rgba(15,26,51,.04);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
body { font-family: 'Pretendard', system-ui, sans-serif; color: var(--text); min-height: 100vh; background: radial-gradient(60vw 60vw at 90% -10%, #c9dbff 0, transparent 60%), radial-gradient(50vw 50vw at -10% 110%, #dcd3ff 0, transparent 55%), linear-gradient(180deg, var(--bg1), var(--bg2)); background-attachment: fixed; -webkit-font-smoothing: antialiased; }
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; cursor: pointer; }
.muted { color: var(--muted); } .small { font-size: 12.5px; }
.glass { background: var(--glass); border: 1px solid var(--glass-b); backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%); box-shadow: var(--shadow); border-radius: 22px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; }
.brand-mark { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: linear-gradient(135deg, var(--blue), var(--violet)); color: #fff; font-size: 15px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 14px; transition: transform .12s, box-shadow .2s, background .2s; white-space: nowrap; }
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(135deg, var(--blue), #4f86ff); color: #fff; box-shadow: 0 6px 18px rgba(47,107,255,.35); }
.btn.ghost { background: rgba(255,255,255,.7); border: 1px solid var(--line); }
.btn.danger { background: #fff0ef; color: var(--red); border: 1px solid #ffd6d2; }
.btn.small { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* LOGIN */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(400px, 100%); padding: 36px; display: flex; flex-direction: column; gap: 14px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 500; }
input, select, textarea { background: rgba(255,255,255,.85); border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px; font-size: 14px; outline: none; transition: border-color .2s, box-shadow .2s; }
input:focus, select:focus, textarea:focus { border-color: var(--blue2); box-shadow: 0 0 0 4px rgba(47,107,255,.12); }
.err { color: var(--red); font-size: 13px; min-height: 18px; }

/* LAYOUT */
.app { display: grid; grid-template-columns: 240px 1fr; gap: 20px; padding: 20px; min-height: 100vh; }
.side { position: sticky; top: 20px; height: calc(100vh - 40px); padding: 22px 14px; display: flex; flex-direction: column; gap: 22px; }
.side .brand { padding: 0 8px; }
#menu { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
#menu a { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 12px; font-size: 14.5px; font-weight: 500; color: #3a4560; transition: background .15s; }
#menu a:hover { background: rgba(255,255,255,.7); }
#menu a.active { background: #fff; color: var(--blue); font-weight: 700; box-shadow: 0 4px 14px rgba(47,107,255,.12); }
.pill { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--red); color: #fff; font-size: 11px; display: inline-grid; place-items: center; }
.side-foot { display: flex; flex-direction: column; gap: 10px; padding: 0 8px; }
.live { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 0 rgba(22,163,106,.5); animation: ping 1.8s infinite; }
.live.off .live-dot { background: var(--red); animation: none; }
@keyframes ping { 70% { box-shadow: 0 0 0 8px rgba(22,163,106,0); } }
.main { min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.top { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.top h1 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.top-actions { display: flex; gap: 10px; align-items: center; }
.search { width: 260px; }
.bell { position: relative; width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; }
.bell .pill { position: absolute; top: -6px; right: -6px; }

/* CARDS */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.kpi { padding: 20px; display: flex; flex-direction: column; gap: 6px; }
.kpi .ic { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-size: 18px; margin-bottom: 6px; }
.kpi strong { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.kpi .sub { font-size: 12.5px; color: var(--muted); }
.kpi .up { color: var(--green); font-weight: 700; }
.grid2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; }
.panel { padding: 20px; min-width: 0; }
.panel h3 { font-size: 15px; font-weight: 700; margin-bottom: 14px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.chart { width: 100%; height: 220px; }
.donut-wrap { display: flex; align-items: center; gap: 20px; }
.legend { display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.list { display: flex; flex-direction: column; }
.list-row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.list-row:last-child { border-bottom: 0; }
.bar { height: 6px; border-radius: 99px; background: rgba(47,107,255,.12); overflow: hidden; margin-top: 6px; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--blue), var(--violet)); border-radius: 99px; }

/* TABLE */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.seg { display: inline-flex; background: rgba(255,255,255,.6); border: 1px solid var(--line); border-radius: 12px; padding: 3px; }
.seg button { padding: 6px 12px; border-radius: 9px; font-size: 13px; color: var(--muted); }
.seg button.active { background: #fff; color: var(--text); font-weight: 600; box-shadow: 0 2px 8px rgba(15,26,51,.06); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:hover td { background: rgba(255,255,255,.5); }
tr.flash td { animation: flash 2s; }
@keyframes flash { from { background: rgba(47,107,255,.15); } }
.tag { display: inline-block; padding: 3px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.t-green { background: #e3f7ee; color: var(--green); } .t-blue { background: #e6eeff; color: var(--blue); } .t-amber { background: #fff4dd; color: var(--amber); } .t-red { background: #ffebe9; color: var(--red); } .t-gray { background: #eef0f5; color: var(--muted); } .t-violet { background: #efeaff; color: var(--violet); }
.thumb { width: 44px; height: 52px; border-radius: 10px; display: grid; place-items: center; }
.thumb svg { width: 80%; }
td select { padding: 6px 8px; border-radius: 9px; font-size: 13px; }
.empty { text-align: center; padding: 40px; color: var(--muted); }

/* MODAL / ALERTS / TOAST */
.modal { position: fixed; inset: 0; background: rgba(15,26,51,.25); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal-card { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; padding: 28px; display: flex; flex-direction: column; gap: 14px; background: rgba(255,255,255,.92); }
.modal-card h3 { font-size: 20px; font-weight: 800; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; }
.alert-panel { position: fixed; top: 76px; right: 24px; width: min(380px, calc(100% - 32px)); max-height: 70vh; overflow-y: auto; z-index: 40; padding: 14px; background: rgba(255,255,255,.92); }
.alert-item { display: flex; gap: 10px; padding: 10px; border-radius: 12px; font-size: 13.5px; }
.alert-item.unread { background: #eef3ff; }
.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 80; }
.toast { background: #0f1a33; color: #fff; padding: 12px 16px; border-radius: 14px; font-size: 14px; box-shadow: 0 10px 30px rgba(15,26,51,.3); animation: tin .3s; max-width: 360px; }
@keyframes tin { from { opacity: 0; transform: translateY(10px); } }
.sys-card { padding: 18px; display: flex; flex-direction: column; gap: 8px; }
.sys-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.sys-card.locked { opacity: .75; background: repeating-linear-gradient(-45deg, rgba(255,255,255,.55), rgba(255,255,255,.55) 10px, rgba(238,240,245,.6) 10px, rgba(238,240,245,.6) 20px); }
code { background: rgba(15,26,51,.06); padding: 2px 6px; border-radius: 6px; font-size: 12.5px; }

@media (max-width: 1100px) { .kpis { grid-template-columns: 1fr 1fr; } .grid2 { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; padding: 12px; }
  .side { position: static; height: auto; }
  #menu { flex-direction: row; overflow-x: auto; }
  #menu a { white-space: nowrap; }
  .side-foot { flex-direction: row; justify-content: space-between; align-items: center; }
  .search { width: 100%; } .top-actions { width: 100%; }
  .kpis, .form-grid { grid-template-columns: 1fr; }
}
