:root {
  --brand: #0b4f8a;
  --brand-ink: #ffffff;
  --brand-soft: #e8f0f8;
  --bg: #f5f6f8;
  --card: #ffffff;
  --ink: #1c2430;
  --muted: #657084;
  --line: #e1e5eb;
  --danger: #b42318;
  --ok: #157f3b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
a { color: var(--brand); }
[hidden] { display: none !important; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  padding: 12px 24px; background: var(--brand); color: var(--brand-ink);
}
.brand { font-weight: 700; font-size: 18px; letter-spacing: .2px; color: inherit; text-decoration: none; display: flex; align-items: center; gap: 10px; }
.brand .mark { width: 30px; height: 30px; border-radius: 8px; background: rgba(255,255,255,.18); display: grid; place-items: center; font-size: 16px; }
.brand small { font-weight: 400; opacity: .8; }
.spacer { flex: 1; }
.userchip { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: rgba(255,255,255,.25); object-fit: cover; display: grid; place-items: center; font-weight: 600; flex: none; }
.avatar.sm { width: 28px; height: 28px; font-size: 12px; background: var(--brand-soft); color: var(--brand); }
.topbar .btn { background: rgba(255,255,255,.14); color: #fff; border-color: transparent; }
.topbar .btn:hover { background: rgba(255,255,255,.24); }

/* Buttons & inputs */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font: inherit; font-size: 14px; cursor: pointer; text-decoration: none;
}
.btn:hover { background: #f0f2f5; }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
input[type=text], input[type=url], input[type=search], input[type=number], textarea, select {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; font: inherit; font-size: 14px; background: #fff; color: var(--ink);
}
textarea { min-height: 90px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
label.field { display: block; margin-bottom: 14px; font-size: 13px; color: var(--muted); }
label.field > span { display: block; margin-bottom: 5px; font-weight: 600; color: var(--ink); }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; margin: 4px 0; color: var(--ink); }

/* Layout */
.wrap { max-width: 1120px; margin: 0 auto; padding: 28px 24px 60px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; margin: 0; }
.page-head .search { max-width: 320px; margin-left: auto; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(160deg, var(--brand) 0%, #0d3a63 100%); }
.login-card { background: var(--card); border-radius: 20px; padding: 40px 36px; width: 100%; max-width: 400px; text-align: center; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.login-card .mark { width: 56px; height: 56px; border-radius: 16px; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 26px; margin: 0 auto 16px; }
.login-card h1 { margin: 0 0 6px; font-size: 22px; }
.login-card p { margin: 0 0 24px; color: var(--muted); font-size: 14px; }
.gbtn { width: 100%; padding: 12px; font-size: 15px; font-weight: 600; }
.gbtn svg { width: 18px; height: 18px; }
.alert { background: #fef3f2; color: var(--danger); border: 1px solid #fecdca; padding: 10px 12px; border-radius: 10px; font-size: 13px; margin-bottom: 16px; text-align: left; }

/* App tiles */
.category { margin: 26px 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.tile {
  display: flex; flex-direction: column; gap: 10px; padding: 18px; border-radius: var(--radius);
  background: var(--card); box-shadow: var(--shadow); text-decoration: none; color: var(--ink);
  border: 1px solid transparent; transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.tile:hover { transform: translateY(-2px); border-color: var(--brand); box-shadow: 0 6px 18px rgba(16,24,40,.10); }
.tile .name { font-weight: 600; font-size: 15px; }
.tile .desc { font-size: 13px; color: var(--muted); line-height: 1.35; }
.appicon { width: 44px; height: 44px; border-radius: 12px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-size: 24px; font-weight: 700; overflow: hidden; flex: none; }
.appicon img { width: 100%; height: 100%; object-fit: contain; }
.appicon.sm { width: 32px; height: 32px; font-size: 17px; border-radius: 9px; }
.empty { text-align: center; padding: 60px 20px; color: var(--muted); background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.empty .big { font-size: 40px; margin-bottom: 8px; }

/* Admin */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 10px 16px; font: inherit; font-size: 14px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 12px 14px; background: #fafbfc; border-bottom: 1px solid var(--line); }
td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.actions { text-align: right; white-space: nowrap; }
td.actions .btn + .btn { margin-left: 6px; }
.sub { font-size: 12px; color: var(--muted); word-break: break-all; }
.cell-user { display: flex; align-items: center; gap: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-size: 12px; font-weight: 500; }
.chip.gray { background: #eef0f3; color: #475467; }
.chip.ok { background: #e7f6ec; color: var(--ok); }
.chip.warn { background: #fef3f2; color: var(--danger); }
.chip button { border: 0; background: none; color: inherit; cursor: pointer; padding: 0; font-size: 14px; line-height: 1; }
.muted { color: var(--muted); }

dialog { border: 0; border-radius: 18px; padding: 0; width: min(620px, calc(100vw - 32px)); box-shadow: 0 24px 60px rgba(0,0,0,.25); color: var(--ink); }
dialog::backdrop { background: rgba(16, 24, 40, .45); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.dlg-head h2 { margin: 0; font-size: 18px; }
.dlg-body { padding: 20px 22px; max-height: 68vh; overflow-y: auto; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--line); background: #fafbfc; }
.section-title { font-size: 13px; font-weight: 700; margin: 18px 0 8px; }
.checklist { max-height: 200px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: 6px 12px; }
.memberlist { border: 1px solid var(--line); border-radius: 10px; max-height: 260px; overflow-y: auto; }
.memberlist .m { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
.memberlist .m:last-child { border-bottom: 0; }
.memberlist .m .grow { flex: 1; min-width: 0; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #1c2430; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px; z-index: 100; box-shadow: var(--shadow); }
.toast.error { background: var(--danger); }

@media (max-width: 700px) {
  .topbar { padding: 10px 14px; }
  .brand small, .userchip .uname { display: none; }
  .wrap { padding: 20px 14px 40px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .hide-sm { display: none; }
  .page-head .search { max-width: none; margin-left: 0; }
}
