:root {
      --bg-color: #f1f5f9;
      --surface-color: #ffffff;
      --text-main: #0f172a;
      --text-muted: #64748b;
      --primary: #4f46e5;
      --primary-hover: #4338ca;
      --border: #e2e8f0;
      --calc-color: #059669; /* Green for calculated */
      --manual-color: #d97706; /* Amber for manual */
      --danger: #ef4444;
      --danger-hover: #dc2626;
      --input-bg: #f8fafc;
    }
    * { box-sizing: border-box; margin: 0; padding: 0; }
    body {
      font-family: 'Inter', sans-serif;
      background-color: var(--bg-color);
      color: var(--text-main);
      padding: 2rem;
    }
    .container {
      max-width: 1100px;
      margin: 0 auto;
      background: var(--surface-color);
      border-radius: 12px;
      box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
      overflow: hidden;
    }
    .header {
      padding: 1.5rem 2rem;
      border-bottom: 1px solid var(--border);
      display: flex;
      justify-content: space-between;
      align-items: center;
      background: #ffffff;
    }
    .header h2 {
      font-size: 1.5rem;
      font-weight: 700;
      color: var(--text-main);
    }
    .date-switcher {
      display: flex;
      align-items: center;
      gap: 1rem;
      background: var(--input-bg);
      padding: 0.5rem;
      border-radius: 8px;
      border: 1px solid var(--border);
    }
    button {
      cursor: pointer;
      border: none;
      background: var(--primary);
      color: white;
      padding: 0.5rem 1rem;
      border-radius: 6px;
      font-weight: 500;
      font-size: 0.875rem;
      transition: all 0.2s;
    }
    button:hover:not(:disabled) { background: var(--primary-hover); }
    button:disabled { background: var(--text-muted); opacity: 0.5; cursor: not-allowed; }
    
    .btn-icon {
      padding: 0;
      width: 40px;
      height: 40px;
      display: flex;
      align-items: center;
      justify-content: center;
      background: white;
      color: var(--text-main);
      border: 1px solid var(--border);
      border-radius: 6px;
      box-sizing: border-box;
    }
    .btn-icon:hover:not(:disabled) {
      background: #f1f5f9;
    }
    
    .btn-today {
      background: white;
      color: var(--text-main);
      border: 1px solid var(--border);
    }
    .btn-today:hover:not(:disabled) {
      background: #f1f5f9;
    }

    .date-display {
      font-size: 1rem;
      font-weight: 600;
      min-width: 140px;
      text-align: center;
      color: var(--primary);
    }
    
    .table-container {
      overflow-x: auto;
      flex: 1;
    }
    table {
      width: 100%;
      border-collapse: collapse;
      text-align: left;
    }
    th, td {
      padding: 1rem 1.5rem;
      border-bottom: 1px solid var(--border);
      vertical-align: middle;
    }
    th {
      background: #f8fafc;
      font-weight: 600;
      color: var(--text-muted);
      text-transform: uppercase;
      font-size: 0.75rem;
      letter-spacing: 0.05em;
      white-space: nowrap;
    }
    tr:last-child td {
      border-bottom: none;
    }
    
    .input-cell { width: 140px; }
    
    input[type="number"], input[type="text"] {
      width: 100%;
      height: 40px;
      box-sizing: border-box;
      padding: 0 0.625rem;
      border: 1px solid var(--border);
      border-radius: 6px;
      font-family: inherit;
      font-size: 0.875rem;
      background: var(--input-bg);
      transition: border-color 0.2s;
    }
    input[type="number"]:focus, input[type="text"]:focus {
      outline: none;
      border-color: var(--primary);
      background: white;
    }
    input[type="number"] { text-align: right; -moz-appearance: textfield; }
    input[type="number"]::-webkit-inner-spin-button, 
    input[type="number"]::-webkit-outer-spin-button { 
      -webkit-appearance: none; 
      margin: 0; 
    }
    
    /* Styling for the Total Column */
    .total-input-wrapper {
      position: relative;
      display: flex;
      align-items: center;
    }
    .total-input-wrapper input {
      font-weight: 700;
      font-size: 1rem;
      padding-right: 1.5rem; /* space for clear button */
      padding-left: 0.5rem;
      text-align: center;
      height: 40px;
    }
    .calc-val { color: var(--calc-color); }
    .manual-val { color: var(--manual-color); background: #fef3c7 !important; border-color: #fde68a !important; }
    .manual-val:focus { border-color: #f59e0b !important; }
    
    .clear-manual {
      position: absolute;
      right: 0.5rem;
      background: transparent;
      color: var(--manual-color);
      padding: 0;
      width: 24px;
      height: 24px;
      font-size: 1.25rem;
      border: none;
      opacity: 0.7;
    }
    .clear-manual:hover {
      background: transparent;
      opacity: 1;
      transform: scale(1.1);
    }
    
    .actions-cell { width: 60px; text-align: center; }
    .btn-delete {
      background: white;
      border-color: transparent;
      color: var(--text-muted);
    }
    .btn-delete:hover {
      color: var(--danger);
      background: #fef2f2;
      border-color: #fee2e2;
    }
    
    .add-row {
      padding: 1.5rem 2rem;
      display: flex;
      gap: 1rem;
      background: #f8fafc;
      border-top: 1px solid var(--border);
    }
    .add-row input { background: white; }
    
    .empty-state {
      padding: 4rem 2rem;
      text-align: center;
      color: var(--text-muted);
    }
    .empty-state svg {
      margin-bottom: 1rem;
      color: #cbd5e1;
    }
    .empty-state p { font-size: 0.875rem; }
    
    .legend {
      padding: 1rem 2rem;
      display: flex;
      gap: 1.5rem;
      font-size: 0.75rem;
      color: var(--text-muted);
      border-top: 1px solid var(--border);
    }
    .legend-item { display: flex; align-items: center; gap: 0.5rem; }
    .legend-color { width: 12px; height: 12px; border-radius: 3px; }
    .color-calc { background: var(--calc-color); }
    .color-manual { background: var(--manual-color); }
    
    
    .split-layout {
      display: flex;
    }
    .groups-section {
      flex: 0 0 35%;
      border-right: 2px solid var(--border);
      display: flex;
      flex-direction: column;
    }
    .items-section {
      flex: 1;
      display: flex;
      flex-direction: column;
      overflow-x: auto;
    }
    .groups-section .add-row, .items-section .add-row {
      border-top: none;
    }

    /* Responsive Design */
    @media (max-width: 768px) {
      .split-layout {
        flex-direction: column;
      }
      .groups-section {
        flex: none;
        width: 100%;
        border-right: none;
        border-bottom: 2px solid var(--border);
      }
      .items-section {
        flex: none;
        width: 100%;
      }

      body { padding: 0.5rem; }
      .header { flex-direction: column; align-items: stretch; padding: 1rem; }
      .header > div { flex-wrap: wrap; justify-content: space-between; }
      .date-switcher { flex-wrap: wrap; justify-content: center; width: 100%; }
      .departures-flex { flex-direction: column; align-items: stretch; }
      .departure-item { justify-content: space-between; }
      th, td { padding: 0.75rem 0.5rem; }
      .input-cell { min-width: 100px; }
      .add-row { flex-direction: column; padding: 1rem; }
    }
    
    /* Modal & Groups UI */
    .modal-overlay {
      position: fixed; top: 0; left: 0; right: 0; bottom: 0;
      background: rgba(15, 23, 42, 0.6);
      display: flex; align-items: center; justify-content: center;
      z-index: 100;
    }
    .modal-content {
      background: white; width: 500px; max-width: 95vw; max-height: 90vh;
      border-radius: 12px; display: flex; flex-direction: column;
      box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    }
    .modal-header {
      padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border);
      display: flex; justify-content: space-between; align-items: center;
    }
    .modal-header h3 { margin: 0; font-size: 1.25rem; font-weight: 700; }
    .modal-body { padding: 1.5rem; overflow-y: auto; background: #f8fafc; }
    
    .group-card {
      border: 1px solid var(--border); border-radius: 8px; margin-bottom: 1rem;
      background: white; box-shadow: 0 1px 2px rgba(0,0,0,0.05); overflow: hidden;
    }
    .group-card-header {
      display: flex; gap: 0.5rem; padding: 1rem; background: #f1f5f9; border-bottom: 1px solid var(--border);
    }
    .group-card-header input { flex: 1; font-weight: bold; border: 1px solid #cbd5e1; }
    .group-items { padding: 1rem; display: flex; flex-direction: column; gap: 0.75rem; }
    .group-item-row { display: flex; justify-content: space-between; align-items: center; font-size: 0.875rem; }
    .group-item-row input { width: 70px; text-align: center; }
    
    .group-divider { border-right: 2px solid var(--border); }
