:root {
  --primary: #0B5FA5; --primary-dark: #073D6B; --primary-deep: #052A4A; --accent: #F5A623;
  --bg: #F1F5FA; --surface: #fff; --border: #DCE5EF; --text: #0F2237; --muted: #5B6B7B;
  --danger: #D93025; --success: #1E8E3E; --radius: 14px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
input, textarea, select { font: inherit; color: inherit; width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: #fff; outline: none; transition: border .15s, box-shadow .15s; }
input:focus, textarea:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(11,95,165,.12); }
textarea { min-height: 96px; resize: vertical; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 13px; }
label small { font-weight: 400; color: var(--muted); }
.muted { color: var(--muted); } .small { font-size: 12px; } .error { color: var(--danger); font-weight: 600; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 18px; border-radius: 10px; font-weight: 700; transition: .15s; white-space: nowrap; }
.btn.primary { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; box-shadow: 0 6px 18px rgba(11,95,165,.25); }
.btn.primary:hover { transform: translateY(-1px); }
.btn.primary:disabled { opacity: .6; cursor: wait; transform: none; }
.btn.accent { background: var(--accent); color: #1a1a1a; }
.btn.ghost { background: #fff; border: 1px solid var(--border); }
.btn.ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn.danger { background: rgba(217,48,37,.08); color: var(--danger); }
.btn.small { padding: 7px 12px; font-size: 13px; }
.icon { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; color: var(--muted); }
.icon:hover { background: var(--bg); color: var(--text); }
.icon.danger:hover { background: rgba(217,48,37,.08); color: var(--danger); }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(900px 500px at 80% -10%, #1f7fd0 0%, transparent 60%), linear-gradient(160deg, var(--primary-deep), var(--primary)); }
.login-card { width: 100%; max-width: 400px; background: #fff; border-radius: 24px; padding: 36px; display: flex; flex-direction: column; gap: 16px; box-shadow: 0 30px 80px rgba(5,42,74,.35); text-align: center; }
.login-logo { width: 72px; height: 72px; margin: 0 auto; }
.login-card h1 { font-size: 22px; font-weight: 800; }
.login-card label { text-align: left; }
.login-card .btn { margin-top: 6px; }

/* layout */
.app { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar { background: var(--primary-deep); color: #fff; padding: 22px 16px; display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px; }
.brand img { width: 42px; height: 42px; background: #fff; border-radius: 12px; padding: 4px; }
.brand b { display: block; font-size: 16px; } .brand small { color: rgba(255,255,255,.6); font-size: 12px; }
#menu { display: flex; flex-direction: column; gap: 4px; flex: 1; }
#menu button { text-align: left; padding: 11px 14px; border-radius: 10px; color: rgba(255,255,255,.75); font-weight: 600; transition: .15s; }
#menu button:hover { background: rgba(255,255,255,.08); color: #fff; }
#menu button.active { background: rgba(255,255,255,.14); color: #fff; }
.sidebar-foot { display: flex; flex-direction: column; gap: 8px; }
.sidebar-foot .btn.ghost { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.15); color: #fff; }
.sidebar-foot small { color: rgba(255,255,255,.5); word-break: break-all; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 22px 32px; background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.topbar h2 { font-size: 20px; font-weight: 800; }
.topbar-actions { display: flex; gap: 10px; }
.content { padding: 28px 32px 60px; display: flex; flex-direction: column; gap: 18px; }

/* list */
.list { display: flex; flex-direction: column; gap: 10px; }
.row { display: grid; grid-template-columns: 64px 1fr auto; gap: 16px; align-items: center; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; transition: .15s; }
.row:hover { box-shadow: 0 6px 20px rgba(11,95,165,.08); }
.row.inactive { opacity: .55; }
.thumb { width: 64px; height: 64px; border-radius: 10px; background: var(--bg); overflow: hidden; display: grid; place-items: center; color: var(--muted); font-weight: 800; }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; }
.row-body { min-width: 0; }
.row-body b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-body small { color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: rgba(11,95,165,.1); color: var(--primary); margin-right: 6px; }
.pill.off { background: rgba(217,48,37,.1); color: var(--danger); }
.row-actions { display: flex; gap: 2px; align-items: center; }
.empty { text-align: center; color: var(--muted); padding: 60px 20px; background: #fff; border: 1px dashed var(--border); border-radius: var(--radius); }
.group-title { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 800; margin: 12px 0 -4px; }

/* settings cards */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 18px; }
.scard { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.scard h3 { font-size: 16px; font-weight: 800; display: flex; justify-content: space-between; align-items: center; }
.scard h3 small { font-weight: 500; color: var(--muted); font-size: 12px; }
.scard .btn { align-self: flex-end; }

/* form */
.form { display: flex; flex-direction: column; gap: 14px; }
.form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.upload { display: flex; gap: 14px; align-items: center; }
.upload .preview { width: 96px; height: 96px; border-radius: 12px; background: var(--bg); border: 1px dashed var(--border); overflow: hidden; display: grid; place-items: center; color: var(--muted); font-size: 11px; text-align: center; flex-shrink: 0; }
.upload .preview img, .upload .preview video { width: 100%; height: 100%; object-fit: cover; }
.upload .ctl { display: flex; flex-direction: column; gap: 8px; flex: 1; }
.upload input[type=file] { padding: 8px; }
.progress { height: 6px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--primary); width: 0; transition: width .2s; }
.switch { display: flex; align-items: center; gap: 10px; flex-direction: row; cursor: pointer; }
.switch input { width: 44px; height: 24px; appearance: none; background: #cdd6e0; border-radius: 999px; position: relative; cursor: pointer; padding: 0; border: 0; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked { background: var(--success); }
.switch input:checked::after { left: 23px; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(5,42,74,.55); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal-card { width: 100%; max-width: 640px; max-height: 92vh; background: #fff; border-radius: 20px; display: flex; flex-direction: column; box-shadow: 0 40px 100px rgba(0,0,0,.35); animation: up .25s ease; }
@keyframes up { from { transform: translateY(16px); opacity: 0; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 18px; font-weight: 800; }
.modal .form { padding: 22px 24px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--border); }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--text); color: #fff; padding: 12px 20px; border-radius: 12px; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.25); z-index: 60; animation: up .25s ease; }
.toast.err { background: var(--danger); } .toast.ok { background: var(--success); }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  #menu { flex-direction: row; flex-wrap: wrap; }
  .topbar, .content { padding-left: 18px; padding-right: 18px; }
  .row { grid-template-columns: 52px 1fr; }
  .row-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .form .two { grid-template-columns: 1fr; }
}
