/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f1117;
  --surface:   #1a1d27;
  --surface2:  #22263a;
  --border:    #2e3250;
  --accent:    #4f8ef7;
  --accent2:   #7c3aed;
  --success:   #22c55e;
  --danger:    #ef4444;
  --warning:   #f59e0b;
  --text:      #e2e8f0;
  --text-dim:  #8892a4;
  --text-head: #ffffff;
  --radius:    8px;
  --radius-sm: 4px;
  --font-mono: 'Courier New', monospace;
  --font-sans: 'Segoe UI', system-ui, sans-serif;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  min-height: 100vh;
}

/* ===== HEADER ===== */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 16px rgba(0,0,0,0.4);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 0;
  flex-wrap: wrap;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-icon {
  font-size: 28px;
  filter: drop-shadow(0 0 8px var(--accent));
}

h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-head);
  letter-spacing: -0.3px;
}

.header-sub {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 2px;
}

/* ===== FILTER BAR ===== */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.filter-bar label {
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
}

select#monthSelect {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 32px 7px 10px;
  font-size: 13px;
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238892a4' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: border-color 0.2s;
  min-width: 140px;
}

select#monthSelect:focus { border-color: var(--accent); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  white-space: nowrap;
}

.btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }
.btn:not(:disabled):hover { opacity: 0.85; }
.btn:not(:disabled):active { transform: scale(0.97); }

.btn-primary  { background: var(--accent);  color: #fff; }
.btn-success  { background: var(--success); color: #fff; }
.btn-danger   { background: var(--danger);  color: #fff; }
.btn-new      { background: var(--surface2); color: var(--accent); border: 1px solid var(--accent); }
.btn-sm       { padding: 4px 9px; font-size: 11px; }

/* ===== MAIN ===== */
main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 24px;
}

/* ===== NOTIFICATION ===== */
.notification {
  padding: 12px 18px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 500;
  border-left: 4px solid;
  transition: opacity 0.3s;
}

.notification.success { background: rgba(34,197,94,0.12); border-color: var(--success); color: var(--success); }
.notification.error   { background: rgba(239,68,68,0.12);  border-color: var(--danger);  color: var(--danger); }
.notification.info    { background: rgba(79,142,247,0.12); border-color: var(--accent);  color: var(--accent); }
.notification.hidden  { display: none; }

/* ===== TABLE TOOLBAR ===== */
.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.row-count {
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

/* ===== TABLE WRAPPER ===== */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: 0 4px 24px rgba(0,0,0,0.3);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

/* ===== TABLE HEAD ===== */
thead tr {
  background: var(--surface2);
  border-bottom: 2px solid var(--accent);
}

th {
  padding: 12px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--accent);
  white-space: nowrap;
  user-select: none;
}

.col-actions { text-align: center; min-width: 180px; }

/* ===== TABLE BODY ===== */
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(79,142,247,0.05); }
tbody tr.row-modified { background: rgba(245,158,11,0.07); }
tbody tr.row-new { background: rgba(124,58,237,0.08); border-left: 3px solid var(--accent2); }

td {
  padding: 10px 14px;
  vertical-align: middle;
  font-size: 13px;
}

td.empty-msg {
  text-align: center;
  color: var(--text-dim);
  padding: 48px;
  font-size: 14px;
}

/* ===== EDITABLE CELLS ===== */
td.editable {
  cursor: pointer;
  position: relative;
}

td.editable:hover::after {
  content: '✎';
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--text-dim);
  opacity: 0.6;
}

td.editing { padding: 4px 8px; }

td input.cell-input {
  width: 100%;
  background: var(--surface2);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 5px 8px;
  font-size: 13px;
  font-family: var(--font-sans);
  outline: none;
  box-shadow: 0 0 0 3px rgba(79,142,247,0.15);
}

td input.cell-input[type="date"] { font-family: var(--font-sans); }
td input.cell-input[type="number"] { font-family: var(--font-mono); }

/* ===== ACTION CELL ===== */
td.actions-cell {
  text-align: center;
  white-space: nowrap;
}

.actions-cell .btn { margin: 0 2px; }

/* ===== LOADING ===== */
.loading-row td {
  text-align: center;
  padding: 40px;
  color: var(--text-dim);
}

.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ===== RESPONSIVE ===== */
@media (max-width: 700px) {
  .header-inner { flex-direction: column; align-items: flex-start; }
  main { padding: 12px; }
  th, td { padding: 8px 10px; }
}
