:root {
  --bg: #f4f2ed; --surface: #ffffff; --text: #21272f; --muted: #707a86;
  --border: #e3e0d8; --border-soft: #edeae2;
  --navy: #1e3a5f; --navy-deep: #16293f; --brick: #b14a32;
  --accent: #1e3a5f; --accent-contrast: #ffffff;
  --danger: #a32d2d; --ok: #2f6d1a; --warn: #8a5a06;
  --shadow: 0 1px 2px rgba(30, 42, 60, 0.05), 0 2px 8px rgba(30, 42, 60, 0.05);
  --header-bg: #1e3a5f; --header-text: #f3f5f8;
}
html[data-theme="dark"] {
  --bg: #15171a; --surface: #1f2228; --text: #e8eaed; --muted: #99a1ac;
  --border: #32363e; --border-soft: #282c33;
  --accent: #7ea8d8; --accent-contrast: #10151c;
  --danger: #f09595; --ok: #97c459; --warn: #fac775;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 2px 10px rgba(0, 0, 0, 0.25);
  --header-bg: #10151c; --header-text: #dfe5ec;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

header.app { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: 14px; align-items: center; padding: 12px 20px; background: var(--header-bg); color: var(--header-text); box-shadow: var(--shadow); }
header.app h1 { font-size: 17px; font-weight: 600; letter-spacing: 0.02em; margin: 0 auto 0 0; display: flex; align-items: center; gap: 10px; }
header.app h1 a { color: var(--header-text); }
header.app h1 a:hover { text-decoration: none; opacity: 0.85; }
header.app .logo { width: 26px; height: 26px; flex: none; }
header.app a { color: var(--header-text); opacity: 0.85; font-size: 14px; }
header.app a:hover { opacity: 1; text-decoration: none; }
header.app button { background: transparent; color: var(--header-text); border: 1px solid rgba(255, 255, 255, 0.35); font-size: 13px; padding: 6px 12px; }
header.app button:hover { background: rgba(255, 255, 255, 0.12); }
header.app select { background: rgba(255, 255, 255, 0.1); color: var(--header-text); border: 1px solid rgba(255, 255, 255, 0.35); font-size: 13px; padding: 6px 8px; border-radius: 8px; }
header.app select option { color: #21272f; background: #fff; }

main { max-width: 1140px; margin: 0 auto; padding: 20px 16px 48px; }
.card { background: var(--surface); border: 1px solid var(--border-soft); border-radius: 14px; padding: 18px 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 12px; font-size: 15px; font-weight: 600; letter-spacing: 0.01em; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.muted { color: var(--muted); font-size: 13px; }
.error { color: var(--danger); font-size: 13.5px; }
.hidden { display: none !important; }

input, select, textarea, button { font: inherit; font-size: 14px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 8px 11px; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent); outline-offset: 0; border-color: var(--accent); }
button { cursor: pointer; transition: background 0.12s ease, transform 0.05s ease; }
button:hover { background: var(--bg); }
button:active { transform: scale(0.98); }
button.primary { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); font-weight: 500; }
button.primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border-soft); }
th { color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; white-space: nowrap; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
th.sortable .arrow { font-size: 10px; margin-left: 3px; }
tbody tr:last-child td { border-bottom: none; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: color-mix(in srgb, var(--accent) 5%, transparent); }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 11px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.b-untested { background: #ece9e1; color: #5d5d55; }
.b-partner { background: #def0cd; color: #27500a; }
.b-unreliable, .b-noanswer { background: #fbdfdc; color: #8c2318; }
.b-closed, .b-notransport { background: #e2e2e2; color: #66666a; }
html[data-theme="dark"] .b-untested { background: #3c3c38; color: #c9c9c0; }
html[data-theme="dark"] .b-partner { background: #2c4513; color: #c0dd97; }
html[data-theme="dark"] .b-unreliable, html[data-theme="dark"] .b-noanswer { background: #54201b; color: #f5bcb4; }
html[data-theme="dark"] .b-closed, html[data-theme="dark"] .b-notransport { background: #36363a; color: #a8a8ae; }
.overdue { color: var(--danger); font-weight: 600; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.stat { background: color-mix(in srgb, var(--bg) 65%, var(--surface)); border: 1px solid var(--border-soft); border-radius: 10px; padding: 10px 13px; overflow-wrap: anywhere; }
.stat .muted { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 2px; }
.stat .v { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }

dialog { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 16px; max-width: 680px; width: 94%; padding: 22px 24px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25); }
dialog::backdrop { background: rgba(15, 20, 30, 0.5); }
dialog h3 { margin-top: 0; }
form.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 11px; }
form.fields label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); font-weight: 500; }
form.fields .section { grid-column: 1 / -1; margin: 6px 0 -4px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); border-bottom: 1px solid var(--border-soft); padding-bottom: 4px; }

#login-overlay { position: fixed; inset: 0; background: linear-gradient(160deg, var(--navy-deep, #16293f), var(--navy, #1e3a5f)); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 20px; z-index: 10; }
#login-overlay .card { width: 320px; max-width: 100%; padding: 28px 30px; border-radius: 18px; }
#login-about { width: 320px; max-width: 100%; text-align: center; color: rgba(255, 255, 255, 0.82); font-size: 12.5px; line-height: 1.55; }
#login-about a { color: #d3e3f7; display: inline-block; margin-top: 6px; }
#login-overlay h2 { margin: 0 0 4px; display: flex; align-items: center; gap: 10px; font-size: 20px; }
#login-overlay .logo { width: 30px; height: 30px; }
.linkish { background: none; border: none; padding: 8px 0 0; color: var(--accent); cursor: pointer; font-size: 13px; text-decoration: underline; display: block; }
.linkish:hover { background: none; opacity: 0.8; }
.pw-reveal { margin-top: 10px; padding: 12px 14px; border-radius: 10px; background: var(--color-background-info, #e6f1fb); border: 1px solid var(--accent); }
html[data-theme="dark"] .pw-reveal { background: #15293f; }
.pw-reveal code { font-size: 17px; font-weight: 600; letter-spacing: 0.5px; }

.meta-line { display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--muted); font-size: 12.5px; margin: 2px 2px 10px; }

.tile-group { margin-bottom: 28px; }
.tile-group:last-child { margin-bottom: 0; }
.tile-group-title { margin: 0 2px 10px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); display: flex; align-items: center; gap: 10px; }
.tile-group-title::after { content: ''; flex: 1; height: 1px; background: var(--border-soft); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.tile { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; text-align: left; padding: 20px 18px; min-height: 130px; background: var(--surface); border: 1px solid var(--border-soft); border-radius: 14px; box-shadow: var(--shadow); transition: transform 0.08s ease, border-color 0.12s ease, background 0.12s ease; }
.tile:hover { background: color-mix(in srgb, var(--accent) 6%, var(--surface)); border-color: var(--accent); transform: translateY(-2px); }
.tile:active { transform: translateY(0) scale(0.99); }
.tile:disabled { opacity: 0.6; cursor: progress; }
.tile-icon { font-size: 30px; line-height: 1; }
.tile-title { font-size: 16px; font-weight: 600; color: var(--text); }
.tile-stat { margin-top: auto; font-size: 11.5px; color: var(--muted); line-height: 1.35; }

.rem-banner { display: flex; align-items: center; gap: 10px; margin: 0 2px 16px; padding: 11px 15px; border-radius: 12px; background: color-mix(in srgb, var(--warn) 14%, var(--surface)); border: 1px solid color-mix(in srgb, var(--warn) 45%, var(--border)); color: var(--text); font-weight: 500; font-size: 14px; box-shadow: var(--shadow); }
.rem-banner:hover { background: color-mix(in srgb, var(--warn) 22%, var(--surface)); }
.rem-banner .rem-ico { font-size: 18px; }
.rem-banner .rem-go { margin-left: auto; color: var(--accent); font-weight: 600; white-space: nowrap; }

.rating-row { display: flex; align-items: center; gap: 12px; padding: 5px 0; }
.rating-label { flex: 1; min-width: 130px; font-size: 14px; }
.star { background: none; border: none; padding: 0 1px; font-size: 23px; line-height: 1; color: var(--border); cursor: pointer; }
.star:hover { background: none; transform: scale(1.12); }
.star.on { color: #f5b301; }
.rating-val { width: 42px; text-align: right; font-size: 12.5px; color: var(--muted); }
.pick-col { width: 26px; text-align: center; }
.pick-col input { cursor: pointer; }

.view-banner { display: flex; align-items: center; gap: 8px; background: color-mix(in srgb, var(--accent) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--border)); border-radius: 12px; padding: 10px 14px; margin: 0 2px 14px; font-size: 14px; }
body.viewer .editor-only { display: none !important; }

.ffield { display: flex; flex-direction: column; gap: 3px; }
.ffield > span { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.hfield { display: flex; align-items: center; gap: 6px; font-size: 12px; opacity: 0.9; }

.card { overflow-x: auto; }

@media (max-width: 640px) {
  main { padding: 12px 8px 32px; }
  .card { padding: 14px; border-radius: 12px; }
  th, td { padding: 7px 6px; }
}
