:root {
  --bg: #0d1b2a;
  --bg-2: #10243a;
  --panel: #0a1522;
  --line: #1c334d;
  --text: #dce7f2;
  --dim: #5f7d9c;
  --amber: #e6b31e;
  --green: #2ecc71;
  --red: #e74c3c;
  --white: #eef3f8;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
}

body {
  font-family: "SF Mono", "Cascadia Mono", "Roboto Mono", "Menlo", "Consolas", monospace;
  background: var(--bg);
  background-image:
    linear-gradient(rgba(230,179,30,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(230,179,30,0.025) 1px, transparent 1px);
  background-size: 22px 22px;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Header */
.board-header {
  padding: calc(14px + env(safe-area-inset-top)) 16px 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(10,21,34,0.6);
}
.header-title {
  font-size: 22px;
  letter-spacing: 8px;
  color: var(--amber);
  font-weight: 700;
  text-shadow: 0 0 10px rgba(230,179,30,0.45);
}
.header-sub {
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--dim);
  margin-top: 3px;
}

/* Views */
.views {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 120px;
  -webkit-overflow-scrolling: touch;
}
.view { display: none; }
.view.active { display: block; }

/* Section labels */
.section-label {
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--dim);
  margin: 16px 0 8px;
  border-left: 3px solid var(--amber);
  padding-left: 8px;
}

/* Counters */
.counters {
  display: flex;
  align-items: stretch;
  gap: 10px;
}
.counter {
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 10px;
}
.counter-label {
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--dim);
  margin-bottom: 8px;
}
.split {
  display: flex;
  gap: 4px;
  justify-content: center;
}
.digit {
  position: relative;
  width: 28px;
  height: 46px;
  background: linear-gradient(180deg, #0e2032 0%, #08121d 55%, #0d1f30 100%);
  border: 1px solid #24405f;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  font-weight: 700;
  color: var(--amber);
  text-shadow: 0 0 8px rgba(230,179,30,0.5);
  box-shadow: inset 0 0 6px rgba(0,0,0,0.7), 0 3px 4px rgba(0,0,0,0.5);
}
.digit::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 2px;
  background: rgba(0,0,0,0.55);
  transform: translateY(-50%);
  border-top: 1px solid rgba(230,179,30,0.08);
}
.split.mode-packed .digit {
  color: var(--white);
  text-shadow: 0 0 8px rgba(238,243,248,0.35);
}

.quick-add {
  width: 64px;
  align-self: stretch;
  background: radial-gradient(circle at 50% 35%, #1c3b2a, var(--panel));
  border: 1px solid var(--green);
  color: var(--green);
  font-size: 34px;
  font-weight: 700;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: 0 0 14px rgba(46,204,113,0.35);
}
.quick-add:active {
  background: rgba(46,204,113,0.25);
}

/* Departure list */
.departure-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(13,27,42,0.55);
  border: 1px solid var(--line);
  border-left: 3px solid transparent;
  padding: 12px 10px;
  cursor: pointer;
  touch-action: pan-y;
  user-select: none;
  position: relative;
  overflow: hidden;
}
.row.due-soon { border-left-color: var(--amber); }
.row.overdue { border-left-color: var(--red); }
.row.packed { border-left-color: var(--green); opacity: 0.92; }

.row.flash { animation: flash 1.1s ease; }
@keyframes flash { 0%{background:#1b324d;} 100%{background:rgba(13,27,42,0.55);} }

.row-num {
  width: 30px;
  flex-shrink: 0;
  font-size: 12px;
  color: var(--dim);
  text-align: right;
  font-weight: 700;
}
.row-body {
  flex: 1;
  min-width: 0;
}
.row-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--amber);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-sub {
  font-size: 11px;
  color: var(--dim);
  margin-top: 2px;
}
.row-cat {
  flex-shrink: 0;
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--text);
  border: 1px solid var(--line);
  padding: 3px 6px;
}
.gate {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.18);
}
.gate.packed { background: var(--green); }
.gate.pending-soon {
  background: var(--amber);
  box-shadow: 0 0 10px 2px rgba(230,179,30,0.6);
}
.gate.pending-on-time { background: var(--white); }
.gate.overdue {
  background: var(--red);
  box-shadow: 0 0 8px 2px rgba(231,76,60,0.5);
}

/* Mini upcoming rows */
.departure-list.mini .row { padding: 9px 10px; }
.departure-list.mini .row-title { font-size: 13px; }
.departure-list.mini .row-num { width: 24px; }

/* Search */
.search-row { margin-top: 16px; }
.search {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 12px;
  font-family: inherit;
  font-size: 14px;
  border-radius: 4px;
}
.search:focus { outline: none; border-color: var(--green); }
.search::placeholder { color: var(--dim); }

/* Empty state */
.empty {
  text-align: center;
  color: var(--dim);
  font-size: 14px;
  letter-spacing: 1px;
  padding: 40px 20px;
  border: 1px dashed var(--line);
  line-height: 1.9;
}
.empty span { font-size: 12px; color: var(--amber); }

/* Form */
.form-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 16px;
  margin-top: 6px;
}
.form-title {
  font-size: 13px;
  letter-spacing: 2px;
  color: var(--amber);
  margin-bottom: 16px;
  text-align: center;
}
label {
  display: block;
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--dim);
  margin: 12px 0 6px;
}
input[type=text], input[type=date], select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 12px;
  font-family: inherit;
  font-size: 14px;
  border-radius: 4px;
}
input:focus, select:focus { outline: none; border-color: var(--amber); }
.field-error {
  font-size: 11px;
  color: var(--red);
  min-height: 14px;
  margin-top: 4px;
}
.save-btn {
  width: 100%;
  margin-top: 18px;
  padding: 14px;
  background: linear-gradient(180deg, #1c3b2a, #123123);
  border: 1px solid var(--green);
  color: var(--green);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2px;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 0 0 12px rgba(46,204,113,0.25);
}
.save-btn:active { background: rgba(46,204,113,0.3); }

/* Tab bar */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 520px;
  display: flex;
  background: rgba(10,21,34,0.96);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 20;
}
.tab {
  flex: 1;
  padding: 14px 0;
  background: none;
  border: none;
  border-top: 3px solid transparent;
  color: var(--dim);
  font-family: inherit;
  cursor: pointer;
  position: relative;
}
.tab-code {
  font-size: 12px;
  letter-spacing: 2px;
  font-weight: 700;
  transition: all 0.2s;
}
.tab.active {
  color: var(--green);
  border-top-color: var(--green);
  text-shadow: 0 0 8px rgba(46,204,113,0.5);
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(5,10,18,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 40;
}
.modal-panel {
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 18px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.6);
}
.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 16px;
}
.btn {
  padding: 12px;
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 1px;
  font-weight: 700;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
}
.btn-ghost { color: var(--dim); }
.btn-save { border-color: var(--green); color: var(--green); }
.btn-danger { border-color: var(--red); color: var(--red); }

.hidden { display: none !important; }

@media (max-width: 380px) {
  .digit { width: 24px; height: 40px; font-size: 26px; }
}