:root {
  --bg: #eef5ff;
  --surface: #ffffff;
  --surface-soft: #f7fbff;
  --ink: #132238;
  --muted: #607189;
  --line: #d9e6f7;
  --blue: #1769e0;
  --blue-dark: #0d408c;
  --blue-soft: #dcecff;
  --cyan: #11a8c7;
  --green: #15936b;
  --red: #c94b5d;
  --shadow: 0 20px 60px rgba(20, 76, 142, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(23, 105, 224, 0.08), transparent 320px),
    var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 20px;
  background: #082b60;
  color: #ffffff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 34px;
}

.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 8px;
  background: #ffffff;
  color: var(--blue-dark);
  font-weight: 900;
}

.brand h1 {
  margin: 0;
  font-size: 1.3rem;
  letter-spacing: 0;
}

.brand p,
.eyebrow,
.panel-header p,
.kpi small {
  margin: 0;
  color: var(--muted);
}

.brand p {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.9rem;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.76);
  background: transparent;
  text-align: left;
}

.nav-item:hover,
.nav-item.is-active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.14);
}

.main {
  min-width: 0;
  padding: 30px clamp(18px, 4vw, 46px) 46px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.eyebrow {
  margin-bottom: 4px;
  color: var(--blue);
  font-size: 0.77rem;
  font-weight: 800;
  text-transform: uppercase;
}

.topbar h2 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.4rem);
  letter-spacing: 0;
}

.period-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-width: 196px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(20, 76, 142, 0.08);
}

.period-button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-weight: 700;
}

.period-button.is-active {
  color: #ffffff;
  background: var(--blue);
}

.settings-button {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 16px;
  color: var(--blue-dark);
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(20, 76, 142, 0.08);
  font-weight: 800;
}

.settings-button:hover {
  border-color: #b9d0ee;
  background: var(--surface-soft);
}

.view {
  display: none;
}

.view.is-active {
  display: grid;
  gap: 18px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.kpi,
.panel,
.notice {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.kpi {
  min-height: 138px;
  padding: 20px;
}

.kpi span {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.kpi strong {
  display: block;
  margin: 12px 0 6px;
  font-size: clamp(1.55rem, 2.8vw, 2.35rem);
  line-height: 1;
  letter-spacing: 0;
}

.kpi-accent {
  color: #ffffff;
  background: linear-gradient(135deg, #1769e0, #0e4ea8);
  border-color: transparent;
}

.kpi-accent span,
.kpi-accent small {
  color: rgba(255, 255, 255, 0.82);
}

.dashboard-grid,
.two-column {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.55fr);
  gap: 18px;
  align-items: start;
}

.panel {
  min-width: 0;
  padding: 20px;
}

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

.panel-header h3 {
  margin: 0 0 3px;
  font-size: 1.05rem;
}

.chart-panel canvas {
  display: block;
  width: 100%;
  height: 340px;
}

.split-list,
.mini-stats,
.task-highlights {
  display: grid;
  gap: 10px;
}

.split-row,
.mini-stats > div,
.watch-item,
.task-item,
.sheet-grid > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 52px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.split-row span,
.mini-stats span,
.task-meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.mini-stats > div {
  display: grid;
  align-items: start;
}

.mini-stats strong {
  margin-top: 6px;
  font-size: 1.7rem;
}

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

.sheets-form {
  grid-template-columns: 1fr;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid #cbdcf1;
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: #ffffff;
  outline: 0;
}

textarea {
  min-height: 92px;
  padding-top: 12px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(23, 105, 224, 0.12);
}

.password-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.field-button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--blue-dark);
  background: #ffffff;
  font-weight: 800;
}

.full-span {
  grid-column: 1 / -1;
}

.primary-button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  color: #ffffff;
  background: var(--blue);
  font-weight: 800;
}

.primary-button:hover {
  background: var(--blue-dark);
}

.table-wrap {
  overflow-x: auto;
}

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

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

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

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

td.amount-col {
  font-weight: 800;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue-dark);
  font-size: 0.82rem;
  font-weight: 800;
}

.status-select {
  min-height: 34px;
  width: auto;
  min-width: 132px;
  padding: 0 32px 0 10px;
  border-radius: 999px;
  background-color: var(--blue-soft);
  color: var(--blue-dark);
  font-size: 0.82rem;
  font-weight: 800;
}

.status-paid,
.status-done {
  background: #dff8ee;
  color: var(--green);
}

.status-late {
  background: #ffe6eb;
  color: var(--red);
}

.ghost-button,
.icon-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--blue-dark);
  background: #ffffff;
  font-weight: 800;
}

.icon-button {
  width: 34px;
}

.password-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.notice {
  padding: 14px 16px;
  color: var(--blue-dark);
  background: #e6f1ff;
}

.watch-list,
.task-list,
.sheet-grid {
  display: grid;
  gap: 10px;
}

.task-item.is-done {
  opacity: 0.58;
}

.task-main {
  display: grid;
  gap: 4px;
}

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

.empty-state {
  min-height: 76px;
  display: grid;
  place-items: center;
  border: 1px dashed #b7cce8;
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface-soft);
  text-align: center;
}

.settings-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 20px;
  background: rgba(8, 43, 96, 0.32);
}

.settings-overlay.is-open {
  display: flex;
}

.settings-panel {
  width: min(520px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(8, 43, 96, 0.22);
}

.settings-section {
  display: grid;
  gap: 12px;
  margin-top: 22px;
}

.settings-section h4 {
  margin: 0;
  font-size: 0.95rem;
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
    padding: 18px;
  }

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

  .nav-item {
    text-align: center;
  }

  .kpi-grid,
  .dashboard-grid,
  .two-column,
  .sheet-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .main {
    padding: 22px 14px 34px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .period-switch {
    width: 100%;
  }

  .nav,
  .kpi-grid,
  .dashboard-grid,
  .two-column,
  .form-grid,
  .sheet-grid {
    grid-template-columns: 1fr;
  }

  .chart-panel canvas {
    height: 280px;
  }
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.sync-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.sync-ok {
  color: var(--green);
}

.sync-pending {
  color: var(--blue);
}

.sync-error {
  color: var(--red);
}