:root {
  --bg: #f4f7f9;
  --surface: #ffffff;
  --surface-soft: #eef3f6;
  --sidebar: #10221f;
  --sidebar-2: #17322d;
  --text: #17212b;
  --muted: #657383;
  --line: #d9e2e8;
  --accent: #0f8b6f;
  --accent-2: #116a8b;
  --warning: #b7791f;
  --danger: #c2413a;
  --success: #138a55;
  --shadow: 0 10px 24px rgba(16, 34, 31, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

a {
  color: inherit;
}

.app-shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 246px;
  padding: 22px 16px;
  background: var(--sidebar);
  color: #ecfdf5;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  margin-bottom: 18px;
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(16, 34, 31, 0.12);
  border-radius: 50%;
  background: #ffffff url("/img/logo-kds.png") center / contain no-repeat;
  color: transparent;
  font-size: 0;
  font-weight: 800;
  flex: 0 0 46px;
}

.brand-title {
  display: block;
  font-size: 17px;
  font-weight: 800;
}

.brand-subtitle {
  display: block;
  color: #a7c7bd;
  font-size: 12px;
}

.menu {
  display: grid;
  gap: 4px;
}

.menu a {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 10px 12px;
  border-radius: 8px;
  color: #c8ddd6;
  font-size: 14px;
  font-weight: 650;
  text-decoration: none;
}

.menu a:hover,
.menu a.active {
  background: var(--sidebar-2);
  color: #ffffff;
}

.main {
  margin-left: 246px;
  padding: 28px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.page-title {
  margin: 0;
  font-size: 28px;
  line-height: 1.16;
}

.page-subtitle {
  margin: 7px 0 0;
  color: var(--muted);
}

.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.grid {
  display: grid;
  gap: 14px;
}

.stats-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.content-grid {
  grid-template-columns: minmax(0, 1.65fr) minmax(280px, 0.8fr);
}

.card,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.card {
  padding: 18px;
}

.panel {
  padding: 20px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-title {
  margin: 0;
  font-size: 18px;
}

.kicker {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stat-value {
  margin-top: 8px;
  font-size: 30px;
  font-weight: 850;
  line-height: 1;
}

.stat-note {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 12px 11px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

tbody tr:hover {
  background: #f8fbfc;
}

.text-muted {
  color: var(--muted);
}

.text-right {
  text-align: right;
}

.money {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.active,
.badge.online,
.badge.paid,
.badge.done {
  background: #dff5e9;
  color: #0d7044;
}

.badge.unpaid,
.badge.warning,
.badge.normal,
.badge.process,
.badge.new {
  background: #fff3d8;
  color: #87570d;
}

.badge.overdue,
.badge.isolated,
.badge.offline,
.badge.cancelled,
.badge.high,
.badge.urgent,
.badge.inactive {
  background: #fde4e1;
  color: #9b2d27;
}

.badge.low {
  background: #e6f0ff;
  color: #24538f;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.1;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover {
  filter: brightness(0.98);
}

.btn.primary {
  background: var(--accent);
  color: #ffffff;
}

.btn.secondary {
  background: var(--accent-2);
  color: #ffffff;
}

.btn.warning {
  background: var(--warning);
  color: #ffffff;
}

.btn.danger {
  background: var(--danger);
  color: #ffffff;
}

.btn.ghost {
  border-color: var(--line);
  background: #ffffff;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-field {
  display: grid;
  gap: 6px;
}

.form-field.full {
  grid-column: 1 / -1;
}

.inline-form {
  display: grid;
  min-width: 220px;
  gap: 6px;
}

.inline-form input,
.inline-form select {
  min-height: 32px;
  padding: 6px 8px;
  font-size: 12px;
}

label {
  color: #35434f;
  font-size: 13px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid #cfd9df;
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
}

textarea {
  min-height: 100px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 139, 111, 0.12);
  outline: none;
}

.search-input {
  max-width: 360px;
}

.filter-tabs {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.filter-tabs button {
  min-height: 30px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
}

.filter-tabs button.active {
  background: var(--sidebar-2);
  color: #ffffff;
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background: linear-gradient(145deg, #f5f8f8 0%, #e8f2ef 55%, #f8f2e6 100%);
}

.login-box {
  width: min(420px, 100%);
  padding: 28px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-box h1,
.login-box h2 {
  margin: 0 0 8px;
}

.alert {
  padding: 11px 12px;
  border-radius: 8px;
  margin: 14px 0;
  font-weight: 700;
}

.alert.error {
  background: #fde4e1;
  color: #9b2d27;
}

.alert.warning {
  background: #fff3d8;
  color: #87570d;
}

.alert.success {
  background: #dff5e9;
  color: #0d7044;
}

.code-area {
  min-height: 240px;
  font-family: "Cascadia Mono", Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre;
}

.checkbox-line {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.checkbox-line input {
  width: 18px;
  min-height: 18px;
}

.inline-chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  margin: 3px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}

.summary-list {
  display: grid;
  gap: 10px;
}

.summary-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.summary-item:last-child {
  border-bottom: 0;
}

.empty-state {
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.print-body {
  background: #eef3f6;
}

.print-page {
  max-width: 920px;
  margin: 0 auto;
  padding: 24px;
}

.print-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 14px;
}

.print-sheet {
  min-height: 1120px;
  padding: 44px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.print-header,
.print-footer,
.print-meta {
  display: grid;
  gap: 18px;
}

.print-header {
  grid-template-columns: 1fr auto;
  align-items: start;
  padding-bottom: 24px;
  border-bottom: 2px solid var(--line);
}

.print-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.print-brand h1,
.print-title h2 {
  margin: 0;
}

.print-brand p,
.print-title p,
.print-meta p {
  margin: 4px 0 0;
  color: var(--muted);
}

.print-title {
  text-align: right;
}

.print-title h2 {
  font-size: 30px;
  letter-spacing: 0;
}

.print-meta {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 26px 0;
}

.print-meta strong {
  display: block;
  margin-top: 4px;
}

.print-table {
  min-width: 0;
}

.print-table tfoot th {
  font-size: 15px;
}

.print-note {
  margin-top: 22px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfc;
  color: var(--muted);
}

.print-footer {
  grid-template-columns: 1fr 220px;
  align-items: end;
  margin-top: 60px;
}

.signature-box {
  display: grid;
  min-height: 120px;
  align-content: end;
  text-align: center;
}

@media print {
  .sidebar,
  .print-actions {
    display: none;
  }

  .print-body,
  body {
    background: #ffffff;
  }

  .print-page {
    max-width: none;
    padding: 0;
  }

  .print-sheet {
    min-height: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
  }
}

@media (max-width: 980px) {
  .sidebar {
    position: static;
    width: 100%;
    height: auto;
  }

  .main {
    margin-left: 0;
    padding: 20px;
  }

  .stats-grid,
  .content-grid,
  .form-grid,
  .print-meta,
  .print-footer,
  .print-header {
    grid-template-columns: 1fr;
  }

  .page-header {
    display: grid;
  }
}

@media (max-width: 560px) {
  .main {
    padding: 16px;
  }

  .toolbar,
  .action-row {
    align-items: stretch;
    flex-direction: column;
  }

  .btn,
  .search-input {
    width: 100%;
  }

  .page-title {
    font-size: 24px;
  }
}
