:root {
  --navy: #071d58;
  --navy-hover: #0e2c7a;
  --ice: #ecf7fc;
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --radius: 8px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  font-size: 14px;
  line-height: 1.5;
}

/* Sidebar */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background-color: var(--navy);
  color: #ffffff;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.logo-placeholder {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px dashed rgba(236, 247, 252, 0.35);
  border-radius: var(--radius);
  background-color: rgba(255, 255, 255, 0.04);
}

.logo-box {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 6px;
  background-color: rgba(236, 247, 252, 0.14);
  display: grid;
  place-items: center;
  color: var(--ice);
}

.logo-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.logo-title {
  font-size: 13px;
  font-weight: 600;
  color: #ffffff;
  line-height: 1.25;
}

.logo-sub {
  font-size: 11px;
  color: rgba(236, 247, 252, 0.65);
}

.sidebar ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar button {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  font: inherit;
  font-weight: 500;
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.sidebar button:hover {
  background-color: var(--navy-hover);
  color: #ffffff;
}

.sidebar button.active {
  background-color: var(--ice);
  color: var(--navy);
  font-weight: 600;
}

/* Invoice List Column */
.list-panel {
  width: 220px;
  flex-shrink: 0;
  background-color: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px;
}

.list-header h2 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.list-count {
  font-size: 12px;
  color: var(--muted);
  background-color: var(--bg);
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.clickable-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.clickable-list button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.clickable-list button::after {
  content: "›";
  font-size: 16px;
  color: var(--muted);
  transition: transform 0.15s ease;
}

.clickable-list button:hover {
  background-color: var(--bg);
}

.clickable-list button:hover::after {
  transform: translateX(2px);
}

.clickable-list button.active {
  background-color: var(--ice);
  border-color: #cde7f5;
  color: var(--navy);
  font-weight: 600;
}

.clickable-list button.active::after {
  color: var(--navy);
}

/* Detail Workspace */
.detail {
  flex: 1;
  min-width: 0;
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  padding-bottom: 14px;
}

.detail-title-group {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}

.detail-header h1 {
  font-size: 18px;
  font-weight: 600;
  color: var(--navy);
}

.detail-meta {
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.field input,
.cell-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  color: var(--text);
  background-color: var(--surface);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus,
.cell-input:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(7, 29, 88, 0.08);
}

.cell-input {
  padding: 6px 8px;
  min-width: 90px;
}

.cell-input.num {
  text-align: right;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.table-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: var(--navy);
  color: #ffffff;
  border: none;
  border-radius: 6px;
  padding: 9px 16px;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.btn-primary:hover {
  background-color: var(--navy-hover);
}

.btn-outline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: var(--surface);
  color: var(--navy);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease,
    opacity 0.15s ease;
}

.btn-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.btn-outline:hover:not(:disabled) {
  background-color: var(--ice);
  border-color: #cde7f5;
}

.btn-outline.danger {
  color: var(--danger);
}

.btn-outline.danger:hover:not(:disabled) {
  background-color: var(--danger-bg);
  border-color: #fecaca;
}

.btn-outline:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.save-status {
  font-size: 13px;
  color: var(--muted);
}

/* Table */
.table-wrap {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

thead th {
  background-color: var(--navy);
  color: #ffffff;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 11px 14px;
  white-space: nowrap;
}

tbody td {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  white-space: nowrap;
  vertical-align: middle;
}

tbody tr.data-row {
  cursor: pointer;
  transition: background-color 0.12s ease;
}

tbody tr:nth-child(even) {
  background-color: #f8fbfe;
}

tbody tr.data-row:hover {
  background-color: var(--ice);
}

tbody tr.selected-row {
  background-color: var(--ice);
  box-shadow: inset 3px 0 0 var(--navy);
}

tbody tr.editing-row,
tbody tr.adding-row {
  background-color: #f8fbfe;
}

tbody tr.empty-row:hover {
  background-color: var(--surface);
}

.empty-state {
  text-align: center;
  padding: 36px 16px;
  color: var(--muted);
}

th.num,
td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.summary-row {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--muted);
}

.summary-row strong {
  color: var(--text);
  font-weight: 600;
}

.empty-view {
  color: var(--muted);
  font-size: 14px;
}

.hidden {
  display: none;
}

/* Responsive */
@media (max-width: 820px) {
  body {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    gap: 12px;
  }

  .sidebar ul {
    flex-direction: row;
  }

  .list-panel {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 14px 16px;
  }

  .clickable-list {
    flex-direction: row;
    overflow-x: auto;
  }

  .clickable-list button {
    width: auto;
    white-space: nowrap;
    gap: 8px;
  }

  .detail {
    padding: 20px 16px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
}
