:root {
  --bg: #161A1D;
  --surface: #22272B;
  --surface-2: #2C333A;
  --surface-3: #38414A;
  --border: #3A444E;
  --border-hover: #4D5F6E;
  --text-primary: #E3E8EE;
  --text-secondary: #9BADBC;
  --text-muted: #6B7F8E;
  --accent: #C41E3A;
  --accent-hover: #E0253F;
  --accent-dim: rgba(196, 30, 58, 0.12);
  --amber: #D97706;
  --green: #16A34A;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow: 0 2px 12px rgba(0,0,0,0.5);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.7);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --header-height: 54px;
  --drawer-handle-height: 42px;
  --col-width: 215px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ──────────────────────────────────── */
.app-header {
  height: var(--header-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
}

.logo { display: flex; align-items: center; gap: 9px; }

.logo-mark {
  color: var(--accent);
  font-size: 15px;
  line-height: 1;
}

.logo-text {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-primary);
}

.header-right { display: flex; align-items: center; gap: 8px; }

/* Sync status dot */
.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 0.4s;
  background: var(--text-muted);
}
.sync-syncing  { background: #D97706; box-shadow: 0 0 5px rgba(217,119,6,0.5); }
.sync-synced   { background: #16A34A; box-shadow: 0 0 5px rgba(22,163,74,0.4); }
.sync-offline  { background: var(--accent); }

/* ── Buttons ──────────────────────────────────── */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.15s;
  letter-spacing: 0.02em;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.15s;
  letter-spacing: 0.02em;
}
.btn-secondary:hover { border-color: var(--border-hover); color: var(--text-primary); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  font-family: var(--font);
  transition: color 0.15s;
}
.btn-ghost:hover { color: var(--text-primary); }

/* ── Board ──────────────────────────────────── */
.board-wrapper {
  position: fixed;
  top: var(--header-height);
  left: 0; right: 0;
  bottom: var(--drawer-handle-height);
  overflow-x: auto;
  overflow-y: hidden;
  padding: 14px 14px 0;
}

.board {
  display: flex;
  gap: 10px;
  height: 100%;
  width: max-content;
  min-width: 100%;
  padding-bottom: 14px;
}

/* ── Column ──────────────────────────────────── */
.column {
  width: var(--col-width);
  background: var(--surface);
  border-radius: var(--radius);
  border: none;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: background 0.15s, box-shadow 0.15s;
  overflow: hidden;
}

.column.drag-over {
  box-shadow: inset 0 0 0 2px var(--accent);
  background: #1e1f22;
}

.column-header {
  padding: 10px 11px 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.column-header.today {
  background: var(--accent);
  border-bottom-color: var(--accent-hover);
}

.column-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 5px;
}

.column-title.today { color: #fff; }

.today-dot {
  width: 5px;
  height: 5px;
  background: rgba(255,255,255,0.7);
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.column-header.today .column-count,
.column-header.today .btn-add-card {
  color: rgba(255,255,255,0.75);
}
.column-header.today .btn-add-card:hover {
  color: #fff;
}

.col-right {
  display: flex;
  align-items: center;
  gap: 5px;
}

.column-count {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 600;
  min-width: 12px;
  text-align: right;
}

.btn-add-card {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 1px 3px;
  border-radius: 3px;
  font-size: 17px;
  line-height: 1;
  transition: color 0.15s;
  font-family: var(--font);
  margin-top: -1px;
}
.btn-add-card:hover { color: var(--text-secondary); }

.column-cards {
  flex: 1;
  overflow-y: auto;
  padding: 7px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-height: 50px;
}

.column-cards::-webkit-scrollbar { width: 3px; }
.column-cards::-webkit-scrollbar-track { background: transparent; }
.column-cards::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Card ──────────────────────────────────── */
.card {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border: none;
  border-left: 3px solid var(--client-color, var(--border));
  padding: 9px 10px 9px 11px;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, filter 0.12s;
  user-select: none;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.card:hover {
  filter: brightness(1.12);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.card.dragging { opacity: 0.35; }

.card-code {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-bottom: 3px;
}

.card-description {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.35;
  margin-bottom: 3px;
}

.card-client {
  font-size: 12px;
  color: var(--text-secondary);
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
}

.card-time {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
}

.awaiting-badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 5px;
  border-radius: 3px;
  text-transform: uppercase;
}
.badge-neutral { color: var(--text-muted); }
.badge-amber   { background: rgba(217,119,6,0.18); color: #D97706; }
.badge-red     { background: rgba(196,30,58,0.18); color: var(--accent); }

/* ── Awaiting Drawer ──────────────────────────── */
.awaiting-drawer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 200;
}

.drawer-handle {
  height: var(--drawer-handle-height);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 18px;
  cursor: pointer;
  gap: 10px;
  user-select: none;
  transition: background 0.15s;
}
.drawer-handle:hover { background: var(--surface-2); }

.drawer-handle-bar {
  width: 28px;
  height: 3px;
  background: var(--border-hover);
  border-radius: 2px;
  margin-right: 2px;
}

.drawer-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
}

.drawer-count {
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

.drawer-chevron {
  margin-left: auto;
  font-size: 9px;
  color: var(--text-muted);
  transition: transform 0.25s;
}
.awaiting-drawer.open .drawer-chevron { transform: rotate(180deg); }

.drawer-content {
  height: 0;
  overflow: hidden;
  background: var(--surface);
  border-top: 1px solid transparent;
  transition: height 0.25s cubic-bezier(0.4,0,0.2,1), border-color 0.25s;
}
.awaiting-drawer.open .drawer-content {
  height: 175px;
  border-top-color: var(--border);
}

.drawer-drop-zone {
  height: 100%;
  padding: 10px 14px;
  overflow-x: auto;
  overflow-y: hidden;
}
.drawer-drop-zone.drag-over { background: #150a0d; }

.drawer-cards {
  display: flex;
  gap: 8px;
  height: 100%;
  align-items: flex-start;
}
.drawer-cards .card {
  width: 200px;
  flex-shrink: 0;
}

.drawer-empty {
  font-size: 12px;
  color: var(--text-muted);
  padding: 24px 0;
  text-align: center;
  width: 100%;
  font-style: italic;
}

/* ── Modal ──────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(3px);
}
.modal-overlay.active { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 400px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.18s ease;
}
.modal-wide { width: 680px; }

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.96) translateY(10px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}

.modal-header {
  padding: 16px 18px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}
.modal-header h2 {
  font-size: 14px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  padding: 4px 6px;
  border-radius: 4px;
  transition: color 0.15s;
  font-family: var(--font);
}
.modal-close:hover { color: var(--text-primary); }

.modal-body { padding: 16px 18px; }

.modal-footer {
  padding: 10px 18px 16px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--border);
}

/* ── Forms ──────────────────────────────────── */
.form-group { margin-bottom: 13px; }

.form-group label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 13px;
  padding: 8px 10px;
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--accent); }

.form-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23666'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

.form-hint {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
  display: block;
  min-height: 16px;
}

.client-suggestions {
  position: absolute;
  top: calc(100% + 2px);
  left: 0; right: 0;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  z-index: 20;
  overflow: hidden;
  display: none;
  box-shadow: var(--shadow);
}
.client-suggestion-item {
  padding: 8px 10px;
  cursor: pointer;
  font-size: 12px;
  transition: background 0.1s;
}
.client-suggestion-item:hover { background: var(--surface-2); }

/* ── Card Detail ──────────────────────────────── */
.card-detail-title {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.card-detail-code {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.card-detail-desc {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 230px;
  gap: 20px;
}

/* Time section */
.time-section { margin-bottom: 16px; }
.time-section > label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.time-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 10px;
}

.time-btn {
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 8px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.12s;
  letter-spacing: 0.02em;
}
.time-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.time-btn:active { transform: scale(0.94); }

.time-total {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 10px;
  transition: color 0.3s;
}
.time-total.flash { color: var(--accent); }

.time-log {
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-height: 110px;
  overflow-y: auto;
}
.time-log-entry {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-secondary);
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}
.time-log-entry:last-child { border-bottom: none; }

/* Card actions */
.card-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.btn-awaiting {
  background: rgba(217,119,6,0.12);
  border: 1px solid rgba(217,119,6,0.25);
  color: #D97706;
  padding: 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.15s;
  text-align: center;
  width: 100%;
}
.btn-awaiting:hover { background: rgba(217,119,6,0.22); }

.btn-done {
  background: rgba(22,163,74,0.12);
  border: 1px solid rgba(22,163,74,0.25);
  color: #16A34A;
  padding: 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.15s;
  text-align: center;
  width: 100%;
}
.btn-done:hover { background: rgba(22,163,74,0.22); }

.btn-danger {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.15s;
  text-align: center;
  width: 100%;
}
.btn-danger:hover {
  background: rgba(196,30,58,0.12);
  border-color: rgba(196,30,58,0.4);
  color: var(--accent);
}

/* ── Archive ──────────────────────────────────── */
.archive-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 420px;
  overflow-y: auto;
}

.archive-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  border-left: 3px solid var(--client-color, #333);
  cursor: pointer;
  transition: border-color 0.12s;
}
.archive-item:hover { border-color: var(--border-hover); }

.archive-item-left { display: flex; flex-direction: column; gap: 2px; }
.archive-code {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  text-transform: uppercase;
}
.archive-desc {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
}
.archive-client { font-size: 11px; color: var(--text-secondary); }

.archive-item-right { text-align: right; flex-shrink: 0; }
.archive-time { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.archive-date { font-size: 10px; color: var(--text-muted); margin-top: 2px; }

.archive-empty {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  padding: 32px;
  font-style: italic;
  display: none;
}

/* ── Search input in archive ──────────────────── */
#archive-search {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 12px;
  padding: 6px 10px;
  outline: none;
  transition: border-color 0.15s;
}
#archive-search:focus { border-color: var(--accent); }

/* ── Time Report ──────────────────────────────── */
.modal-report {
  width: 620px;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
}

.report-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.month-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.month-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 26px;
  height: 26px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  font-family: var(--font);
}
.month-btn:hover { border-color: var(--border-hover); color: var(--text-primary); }

.month-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  min-width: 90px;
  text-align: center;
}

.report-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
}

.report-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 13px;
  font-style: italic;
}

.report-day {
  margin-bottom: 18px;
}

.report-day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}

.report-day-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.report-day-total {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.report-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 8px;
  border-radius: 5px;
  transition: background 0.1s;
}
.report-entry:hover { background: var(--surface-2); }

.report-entry-left {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.report-entry-code {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.report-entry-desc {
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.report-entry-client {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
  margin-left: 6px;
}

.report-entry-time {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  flex-shrink: 0;
  margin-left: 12px;
  font-variant-numeric: tabular-nums;
}

.report-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0 16px;
}

.report-client-totals {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.report-totals-heading {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 10px 12px 6px;
}

.report-client-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  border-top: 1px solid var(--border);
}

.report-client-name {
  font-size: 13px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.report-client-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.report-client-time {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.report-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.report-grand-total {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

/* Copy success flash */
.btn-copy-success {
  background: var(--green) !important;
  border-color: var(--green) !important;
}

/* ── Print styles ──────────────────────────────── */
@media print {
  body { background: #fff; color: #000; }
  .app-header, .awaiting-drawer, .board-wrapper,
  .modal-overlay:not(#report-modal-overlay) { display: none !important; }
  #report-modal-overlay {
    position: static;
    background: none;
    display: block !important;
  }
  .modal-report {
    width: 100%;
    max-height: none;
    border: none;
    box-shadow: none;
    background: #fff;
    color: #000;
  }
  .modal-header, .modal-footer { background: #fff; }
  .modal-close, .report-footer > div { display: none; }
  .report-body { overflow: visible; }
  .report-entry:hover { background: transparent; }
  .report-day-name, .report-totals-heading { color: #666; }
  .report-entry-code, .report-entry-client { color: #999; }
  .report-entry-desc, .report-entry-time,
  .report-client-name, .report-client-time,
  .report-grand-total, .month-label { color: #000; }
  .report-day-header { border-bottom-color: #ccc; }
  .report-divider { border-top-color: #ccc; }
  .report-client-totals { background: #f5f5f5; }
  .report-client-row { border-top-color: #ddd; }
  .month-btn { display: none; }
}

/* ── Scrollbars ──────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }
