:root {
  --bg: #10141c;
  --panel: #1a2130;
  --panel-2: #222b3d;
  --text: #e8ecf4;
  --muted: #93a0b5;
  --accent: #4f8cff;
  --danger: #ff6b6b;
  --ok-bg: #17352a;
  --ok-tx: #7ce3ac;
  --err-bg: #3a2020;
  --err-tx: #ff9d9d;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 230px;
  flex-shrink: 0;
  background: var(--panel);
  padding: 20px 14px;
}
.brand {
  display: block;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  margin-bottom: 22px;
}
.brand span { color: var(--accent); }
.side-label {
  margin: 16px 6px 6px;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.side-link {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  margin-bottom: 2px;
}
.side-link:hover { background: var(--panel-2); }
.as-button {
  width: 100%;
  border: 0;
  background: none;
  font: inherit;
  text-align: left;
  cursor: pointer;
  color: var(--danger);
}

.add-own { display: flex; gap: 6px; margin-top: 4px; }
.add-own input {
  flex: 1;
  min-width: 0;
  background: var(--panel-2);
  border: 1px solid #33405a;
  color: var(--text);
  border-radius: 8px;
  padding: 7px 9px;
  font-size: 13px;
}
.add-own button {
  width: 34px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-size: 17px;
  cursor: pointer;
}

.main { flex: 1; display: flex; flex-direction: column; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 26px;
  border-bottom: 1px solid #232d40;
}
.top-title { font-size: 17px; font-weight: 600; }
.pill {
  background: var(--panel-2);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12.5px;
  margin-left: 8px;
  color: var(--muted);
}
.pill.alert { background: #3d2f14; color: #ffd479; font-weight: 600; }

.content { padding: 22px 26px; max-width: 1000px; }

.flash {
  margin: 14px 26px 0;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
}
.flash.ok  { background: var(--ok-bg); color: var(--ok-tx); }
.flash.err { background: var(--err-bg); color: var(--err-tx); }

.card {
  background: var(--panel);
  border: 1px solid #242e42;
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 16px;
}
.card.wide { max-width: 720px; }

.form label, .form fieldset { display: block; margin-bottom: 14px; }
.form input:not([type=checkbox]):not([type=radio]),
.form select,
.form textarea {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid #33405a;
  border-radius: 8px;
  padding: 9px 11px;
  color: var(--text);
  font: inherit;
  margin-top: 5px;
}
fieldset { border: 1px solid #2c3850; border-radius: 10px; padding: 10px 12px; }
legend { color: var(--muted); font-size: 13px; padding: 0 6px; }
.check { display: flex !important; align-items: center; gap: 8px; }
.check input { accent-color: var(--accent); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

button.primary, .btn {
  background: var(--accent);
  color: white;
  border: 0;
  border-radius: 8px;
  padding: 9px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
button.small, button[type=submit]:not(.primary):not(.as-button) {
  background: var(--panel-2);
  border: 1px solid #33405a;
  color: var(--text);
  border-radius: 7px;
  padding: 5px 11px;
  cursor: pointer;
  font-size: 13px;
}
button.link-danger {
  background: none;
  border: 0;
  color: var(--danger);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  text-decoration: underline;
  padding: 0;
}
.muted { color: var(--muted); font-size: 13.5px; }
a { color: var(--accent); }

.notifications { border-left: 3px solid #ffd479; }
.notif-head { display: flex; justify-content: space-between; align-items: center; }
.notif-head h2 { margin: 0; font-size: 15px; }
.notif-row {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 8px 0;
  border-top: 1px solid #26314a;
  font-size: 14px;
}
.notif-row .when { color: var(--muted); min-width: 170px; }
.notif-row form { margin-left: auto; }

.events-head { display: flex; justify-content: space-between; align-items: center; margin: 6px 0 10px; }
.events-head h2 { font-size: 15px; margin: 0; }

table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: 12px; overflow: hidden; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid #242e42; vertical-align: top; font-size: 14px; }
thead th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.date-cell { white-space: nowrap; font-weight: 600; }
.notes { color: var(--muted); font-size: 12.5px; }
.tag.off {
  background: #3a2a2a;
  color: var(--err-tx);
  font-size: 11px;
  border-radius: 6px;
  padding: 1px 6px;
  margin-left: 6px;
}
.tag.ack {
  background: #1f3a2e;
  color: #7fe0aa;
  font-size: 11px;
  border-radius: 6px;
  padding: 1px 6px;
  margin-left: 6px;
}
.row-actions { white-space: nowrap; }
.row-actions form { display: inline; }

/* ---------- Calendar ---------- */
.calendar-card { padding: 18px; }
.cal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.cal-toolbar h2 { margin: 0; font-size: 19px; }
.cal-nav { display: flex; gap: 8px; }
.cal-filter select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid #2c3b55;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13.5px;
}

.cal-dow {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 6px;
}
.cal-dow-cell {
  text-align: center;
  font-size: 11.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 4px 0;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.cal-cell {
  background: var(--panel-2);
  border-radius: 10px;
  min-height: 96px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
}
.cal-cell.empty { background: transparent; }
.cal-cell.today { outline: 2px solid var(--accent); }
.cal-cell.has { background: #1d2636; }
.cal-daynum {
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 5px;
}
.cal-daynum .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
}
.cal-events { display: flex; flex-direction: column; gap: 3px; }

/* ---------- Calendar legend ---------- */
.cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 10px 2px 2px;
  margin-bottom: 10px;
  font-size: 12.5px;
  color: var(--muted);
}
.cal-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.cal-legend-item .swatch {
  width: 10px; height: 10px;
  border-radius: 3px;
  display: inline-block;
}
.cal-legend-item .swatch.c0 { background: #4f8cff; }
.cal-legend-item .swatch.c1 { background: #7c6cff; }
.cal-legend-item .swatch.c2 { background: #2fbf8f; }
.cal-legend-item .swatch.c3 { background: #f2a93b; }
.cal-legend-item .swatch.c4 { background: #e25f7c; }
.cal-legend-item .swatch.c5 { background: #6bb2e3; }
.cal-ev {
  display: block;
  font-size: 11.5px;
  line-height: 1.25;
  padding: 3px 6px;
  border-radius: 6px;
  color: #fff;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-ev.c0 { background: #4f8cff; }
.cal-ev.c1 { background: #7c6cff; }
.cal-ev.c2 { background: #2fbf8f; }
.cal-ev.c3 { background: #f2a93b; }
.cal-ev.c4 { background: #e25f7c; }
.cal-ev.c5 { background: #6bb2e3; }
.cal-more { font-size: 11px; color: var(--muted); padding-left: 4px; }

@media (max-width: 800px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; }
  .grid2 { grid-template-columns: 1fr; }
  .cal-cell { min-height: 60px; }
}
