:root {
  --navy: #3f4f6b; --line: #e2e6ee; --bg: #f4f6fa; --card: #fff; --muted: #6b7280;
  --ok: #1f8a4c; --err: #b23a3a; --orange: #b7791f;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: #1a2230; font-size: 14px; }
a { color: var(--navy); }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, Menlo, monospace; }
.orange { color: var(--orange); }
.grow { flex: 1; }
.center { text-align: center; }

.topbar { display: flex; align-items: center; gap: 20px; background: var(--card); border-bottom: 1px solid var(--line); padding: 10px 18px; }
.topbar .brand { font-size: 16px; }
.topbar nav { display: flex; gap: 6px; }
.topbar nav a { padding: 6px 12px; border-radius: 7px; text-decoration: none; color: #33405a; }
.topbar nav a.active { background: var(--navy); color: #fff; }
.topbar .who { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.badge { background: #eef1f7; border-radius: 6px; padding: 2px 8px; font-size: 12px; text-transform: capitalize; }

main { padding: 16px 18px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
.pad { padding: 18px; }

.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.toolbar h2 { margin: 0; }
input[type=search], input[type=text], input[type=date], textarea, select { font: inherit; padding: 6px 8px; border: 1px solid #cdd4e0; border-radius: 6px; background: #fff; }
textarea { width: 100%; resize: vertical; }

.btn { background: var(--navy); color: #fff; border: none; border-radius: 7px; padding: 8px 14px; cursor: pointer; font: inherit; }
.btn.secondary { background: #eef1f7; color: #33405a; }
.btn.danger { background: #f5e3e3; color: var(--err); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.xs { padding: 2px 7px; font-size: 12px; border-radius: 5px; }
.btn:disabled { opacity: .45; cursor: default; }

.gridwrap { overflow: auto; border: 1px solid var(--line); border-radius: 10px; background: #fff; max-height: calc(100vh - 150px); }
table.sheet { border-collapse: collapse; width: max-content; min-width: 100%; }
table.sheet th, table.sheet td { border: 1px solid var(--line); padding: 3px 6px; text-align: left; white-space: nowrap; }
table.sheet thead th { position: sticky; top: 0; background: #f0f3f9; z-index: 2; font-size: 12px; text-transform: none; }
table.sheet td.pin, table.sheet th.pin { position: sticky; left: 0; background: #fafbfe; z-index: 1; }
table.sheet input[type=text], table.sheet input[type=date], table.sheet select, table.sheet textarea { border: 1px solid transparent; background: transparent; width: 100%; min-width: 90px; padding: 3px 4px; }
table.sheet td.k-longtext { min-width: 220px; white-space: normal; }
table.sheet input:focus, table.sheet select:focus, table.sheet textarea:focus { border-color: #a9b6d0; background: #fff; outline: none; }
table.sheet td.k-checkbox { text-align: center; }
table.sheet th.colhead { cursor: pointer; }
table.sheet th.colhead:hover { background: #e4ebf7; }
table.sheet th.colhead .muted { opacity: 0; }
table.sheet th.colhead:hover .muted { opacity: .7; }
table.sheet th.addcol { cursor: pointer; text-align: center; font-weight: 700; color: var(--navy); min-width: 32px; }
table.sheet th.addcol:hover { background: #e4ebf7; }
.toolbar select#sheetSel { font-weight: 600; min-width: 160px; }

.grid { border-collapse: collapse; width: 100%; margin-top: 8px; }
.grid th, .grid td { border-bottom: 1px solid var(--line); padding: 7px 8px; text-align: left; vertical-align: top; }
.grid th { font-size: 12px; color: #555; text-transform: uppercase; }

.admin { display: grid; grid-template-columns: 200px 1fr; gap: 16px; }
.admin .menu { padding: 8px; display: flex; flex-direction: column; gap: 4px; height: max-content; }
.admin .menu button { text-align: left; background: none; border: none; padding: 8px 10px; border-radius: 6px; cursor: pointer; font: inherit; }
.admin .menu button.active { background: var(--navy); color: #fff; }
.row { display: flex; align-items: center; gap: 10px; }
.field { display: block; margin: 10px 0; }
.field > span { display: block; font-size: 12px; color: #555; margin-bottom: 3px; }
.field input, .field select, .field textarea { width: 100%; }

.modal-back { position: fixed; inset: 0; background: rgba(20,26,40,.45); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: #fff; border-radius: 12px; padding: 20px; width: 440px; max-width: 92vw; }
.modal.wide { width: 680px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.dropzone { border: 2px dashed #c3ccdc; border-radius: 10px; padding: 22px; text-align: center; background: #fafbfe; transition: .15s; }
.dropzone.drag { border-color: var(--navy); background: #eef2fb; }
.link { color: var(--navy); text-decoration: underline; cursor: pointer; }

.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login .card { width: 420px; max-width: 92vw; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(40px); background: #222c3d; color: #fff; padding: 10px 16px; border-radius: 8px; opacity: 0; transition: .2s; pointer-events: none; z-index: 60; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--err); }
[hidden] { display: none !important; }
