:root {
  --bg: #020805;
  --panel: #03150a;
  --panel-2: #052010;
  --text: #8dff9e;
  --text-dim: #3d8a4e;
  --accent: #00ff6a;
  --blue: #2f62e8;
  --blue-dim: #1a3d9a;
  --border: #0d4a22;
  --border-hi: #1a7a38;
  --danger: #ff5d5d;
  --warn: #e8d25a;
  --scan: rgba(0, 80, 20, 0.12);
  --glow: rgba(0, 255, 90, 0.28);
  --font-ui: "IBM Plex Mono", "PT Mono", "Courier New", ui-monospace, monospace;
  --font-data: "Segoe UI", system-ui, -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.45;
}

body {
  text-shadow: 0 0 2px rgba(0, 255, 90, 0.25);
}

.scanlines {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  background: repeating-linear-gradient(
    0deg,
    transparent 0 2px,
    var(--scan) 2px 3px
  );
  opacity: 0.45;
}

.crt {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  max-width: 1440px;
  margin: 0 auto;
  padding: 12px 16px 24px;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 14px;
  background: var(--panel);
  border: 2px solid var(--border);
  box-shadow: 0 0 18px var(--glow), inset 0 0 24px rgba(0, 255, 80, 0.06);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.brand-logo {
  background: #fff;
  border-radius: 2px;
  padding: 4px 8px;
  display: flex;
  align-items: center;
}

.brand-logo img {
  height: 36px;
  width: auto;
  display: block;
}

.brand-text { display: flex; flex-direction: column; }
.brand-sys {
  color: var(--accent);
  letter-spacing: 0.12em;
  font-size: 13px;
}
.brand-sub { color: var(--text-dim); font-size: 11px; }

.top-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.sys-ok {
  color: var(--accent);
  border: 1px solid var(--border-hi);
  padding: 2px 8px;
  animation: pulse 2.8s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.who { color: var(--text-dim); }
.link { color: var(--accent); text-decoration: none; }
.link:hover { text-decoration: underline; }

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  border: 2px solid var(--border);
  border-top: 0;
  background: #021108;
}

.nav a {
  color: var(--text);
  text-decoration: none;
  padding: 8px 14px;
  border-right: 1px solid var(--border);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.06em;
}

.nav a:hover { background: var(--panel-2); color: var(--accent); }
.nav a.active {
  background: #063018;
  color: #fff;
  box-shadow: inset 0 -2px 0 var(--accent);
}

.main { flex: 1; padding: 16px 0; }

.foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 11px;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.dim { color: var(--text-dim); }

h1, h2 {
  font-weight: 400;
  color: var(--accent);
  text-shadow: 0 0 8px var(--glow);
  margin: 0 0 12px;
}
h1 { font-size: 22px; }
h2 { font-size: 16px; margin-top: 22px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 16px;
  box-shadow: inset 0 0 30px rgba(0, 255, 80, 0.04);
  margin-bottom: 16px;
}

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.card {
  border: 1px solid var(--border);
  background: #02140a;
  padding: 12px;
}

.card .n {
  font-size: 28px;
  color: var(--accent);
  font-family: var(--font-data);
}

.card.warn .n { color: var(--warn); }
.card.danger .n { color: var(--danger); }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
  align-items: center;
}

.filter, input, select, textarea, button, .btn {
  font-family: inherit;
  font-size: 14px;
}

.filter {
  flex: 1;
  min-width: 180px;
  background: #001208;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 7px 10px;
}

input, select, textarea {
  background: #001208;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 7px 10px;
  width: 100%;
  text-shadow: none;
}

input[type="file"] {
  width: auto;
  color: var(--text-dim);
  padding: 4px;
}

input[type="checkbox"], input[type="radio"] {
  width: auto;
}

label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin: 8px 0 4px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 4px 12px;
}

.form-grid .span-2 { grid-column: span 2; }
.form-actions { margin-top: 14px; display: flex; gap: 8px; flex-wrap: wrap; }

button, .btn {
  background: #032410;
  color: var(--accent);
  border: 1px solid var(--border-hi);
  padding: 7px 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  box-shadow: 0 0 6px rgba(0, 255, 90, 0.15);
}

button:hover, .btn:hover {
  box-shadow: 0 0 12px rgba(0, 255, 90, 0.4);
  color: #fff;
}

.btn-primary { background: #0a3d1c; }
.btn-tiny {
  padding: 0 6px;
  font-size: 12px;
  line-height: 1.4;
}
.danger, .btn.danger { color: var(--danger); border-color: #7a2020; }
.ghost { opacity: 0.85; }

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  max-height: 70vh;
}

table.data {
  border-collapse: collapse;
  width: 100%;
  font-family: var(--font-data);
  font-size: 13px;
  text-shadow: none;
  min-width: 720px;
}

table.data th, table.data td {
  border-bottom: 1px solid var(--border);
  padding: 6px 8px;
  text-align: left;
  vertical-align: top;
  white-space: pre-wrap;
}

table.data th {
  position: sticky;
  top: 0;
  background: #073016;
  color: var(--accent);
  font-family: var(--font-ui);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  z-index: 2;
  cursor: pointer;
}

table.data tr:nth-child(even) td { background: rgba(0, 40, 15, 0.35); }
table.data tr:hover td { background: rgba(0, 80, 30, 0.45); }
table.data tr.overdue td { background: rgba(120, 40, 0, 0.28); }

.badge {
  display: inline-block;
  padding: 1px 7px;
  border: 1px solid var(--border);
  font-size: 11px;
  font-family: var(--font-ui);
}
.st-plan { color: var(--text-dim); }
.st-way { color: var(--warn); border-color: #7a6a20; }
.st-done { color: var(--accent); }

.flash {
  padding: 10px 12px;
  border: 1px solid var(--border-hi);
  margin-bottom: 14px;
  background: #042010;
}
.flash-warn { border-color: var(--warn); color: var(--warn); }
.flash-err { border-color: var(--danger); color: var(--danger); }

.news-item {
  border-left: 3px solid var(--blue);
  padding: 8px 12px;
  margin-bottom: 10px;
  background: #02100c;
}
.news-item.pinned { border-left-color: var(--accent); }
.news-item h3 { margin: 0 0 4px; font-size: 15px; color: var(--accent); font-weight: 400; }

.files { list-style: none; margin: 0; padding: 0; }
.files li { margin: 2px 0; }
.files a { color: var(--blue); }

.login-box {
  max-width: 420px;
  margin: 48px auto;
}

.check-list {
  max-height: 280px;
  overflow: auto;
  border: 1px solid var(--border);
  padding: 8px;
  background: #011008;
}

.check-list label { color: var(--text); margin: 4px 0; }

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.tabs a {
  color: var(--text-dim);
  text-decoration: none;
  padding: 8px 12px;
  font-size: 12px;
  text-transform: uppercase;
}
.tabs a.active { color: var(--accent); border-bottom: 2px solid var(--accent); }

.inline { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.inline input[type="file"] { width: auto; }

.preview {
  border: 1px dashed var(--border);
  padding: 10px;
  color: var(--text-dim);
  white-space: pre-wrap;
  font-size: 13px;
  margin-top: 8px;
}

.view-val {
  min-height: 1.4em;
  padding: 4px 0;
  white-space: pre-wrap;
  font-family: var(--font-data);
}

table.data th.chk, table.data td.chk {
  width: 36px;
  white-space: nowrap;
  vertical-align: middle;
}

.theme-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}
.theme-row label { margin: 0; color: var(--text); }
.theme-row select { width: auto; min-width: 160px; }

@media (max-width: 720px) {
  .brand-sub { display: none; }
  .brand-logo img { height: 28px; }
  .form-grid .span-2 { grid-column: span 1; }
  table.data { min-width: 640px; }
}

/* Light office theme (default). CRT glow stays on .theme-dark only. */
html.theme-light {
  --bg: #f4f6f4;
  --panel: #ffffff;
  --panel-2: #eef1ee;
  --text: #1a241c;
  --text-dim: #5a6a5e;
  --accent: #2f62e8;
  --green: #1a8f3c;
  --blue: #2f62e8;
  --blue-dim: #1a3d9a;
  --border: #d4ddd6;
  --border-hi: #2f62e8;
  --danger: #c62828;
  --warn: #b8860b;
  --scan: transparent;
  --glow: transparent;
  --font-ui: "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-data: "Segoe UI", system-ui, -apple-system, sans-serif;
}

html.theme-light body {
  text-shadow: none;
  font-family: var(--font-ui);
}

html.theme-light .scanlines {
  display: none;
}

html.theme-light .top {
  box-shadow: none;
  border: 1px solid var(--border);
  background: #fff;
}

html.theme-light .brand-sys {
  color: var(--blue);
  letter-spacing: 0.04em;
}

html.theme-light .sys-ok {
  animation: none;
  color: var(--green);
  border-color: var(--green);
}

html.theme-light .nav {
  background: #fff;
  border: 1px solid var(--border);
  border-top: 0;
}

html.theme-light .nav a {
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  border-right-color: var(--border);
}

html.theme-light .nav a:hover {
  background: #eef3ff;
  color: var(--blue);
}

html.theme-light .nav a.active {
  background: #e8eefc;
  color: var(--blue);
  box-shadow: inset 0 -2px 0 var(--blue);
}

html.theme-light h1,
html.theme-light h2,
html.theme-light .news-item h3 {
  text-shadow: none;
  color: var(--text);
  font-weight: 600;
}

html.theme-light h1 { color: #122018; }
html.theme-light h2 { color: var(--green); }

html.theme-light .panel {
  box-shadow: 0 1px 3px rgba(26, 36, 28, 0.06);
  background: #fff;
}

html.theme-light .card {
  background: #fff;
}

html.theme-light .card .n {
  color: var(--blue);
}

html.theme-light .filter,
html.theme-light input,
html.theme-light select,
html.theme-light textarea {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
}

html.theme-light button,
html.theme-light .btn {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
}

html.theme-light button:hover,
html.theme-light .btn:hover {
  color: var(--blue);
  box-shadow: none;
  background: #eef3ff;
}

html.theme-light .btn-primary {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}

html.theme-light .btn-primary:hover {
  background: #1a4fd0;
  color: #fff;
}

html.theme-light table.data th {
  background: #eef1ee;
  color: #3a4a3e;
  text-transform: none;
  letter-spacing: 0;
  font-family: var(--font-data);
  font-weight: 600;
  font-size: 12px;
}

html.theme-light table.data tr:nth-child(even) td { background: #f7f8f7; }
html.theme-light table.data tr:hover td { background: #e8eefc; }
html.theme-light table.data tr.overdue td { background: #fdecea; }

html.theme-light .flash { background: #eef6ee; }
html.theme-light .flash-warn { background: #fff8e6; }
html.theme-light .flash-err { background: #fdecea; }
html.theme-light .news-item { background: #f8faf8; }
html.theme-light .check-list { background: #fff; }
html.theme-light .tabs a.active { color: var(--blue); border-bottom-color: var(--blue); }
html.theme-light .st-done { color: var(--green); }
html.theme-light .link { color: var(--blue); }

html.theme-dark {
  --green: #00ff6a;
}

html.theme-dark .scanlines {
  display: block;
}
