:root {
  --ink: #17202a;
  --muted: #64748b;
  --line: #d8dee8;
  --surface: #ffffff;
  --wash: #f5f7fa;
  --nav: #25313f;
  --nav-2: #344457;
  --accent: #167f7a;
  --accent-2: #b6405a;
  --warn: #a16207;
  --ok: #237047;
  --shadow: 0 18px 45px rgba(20, 31, 46, 0.1);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--wash);
}

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

button {
  border: 0;
  cursor: pointer;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(22, 127, 122, 0.15), transparent 42%),
    linear-gradient(315deg, rgba(182, 64, 90, 0.12), transparent 40%),
    var(--wash);
}

.login-panel {
  width: min(940px, 100%);
  display: grid;
  grid-template-columns: 1fr 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.brand-pane {
  background: var(--nav);
  color: white;
  padding: 44px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 520px;
}

.brand-pane h1 {
  margin: 0;
  max-width: 620px;
  font-size: clamp(30px, 5vw, 54px);
  line-height: 1.02;
  letter-spacing: 0;
}

.brand-pane p {
  margin: 22px 0 0;
  color: #c9d6e3;
  max-width: 520px;
  line-height: 1.55;
}

.login-form {
  padding: 40px;
  align-self: center;
}

.login-form h2,
.section h2,
.drawer h2 {
  margin: 0 0 18px;
  font-size: 23px;
  letter-spacing: 0;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

label {
  color: #334155;
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(22, 127, 122, 0.16);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.btn {
  min-height: 40px;
  border-radius: 6px;
  padding: 0 14px;
  color: white;
  background: var(--accent);
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn.secondary {
  background: var(--nav-2);
}

.btn.light {
  color: var(--ink);
  background: #e8edf3;
}

.btn.danger {
  background: var(--accent-2);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.link-btn {
  color: var(--accent);
  background: transparent;
  padding: 0;
  font-weight: 900;
  text-decoration: underline;
}

.hint,
.muted {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 268px 1fr;
}

.sidebar {
  background: var(--nav);
  color: white;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.sidebar h1 {
  margin: 0;
  font-size: 21px;
  line-height: 1.18;
  letter-spacing: 0;
}

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

.nav button {
  color: #dce6f0;
  background: transparent;
  text-align: left;
  border-radius: 6px;
  padding: 11px 12px;
  font-weight: 800;
}

.nav button.active,
.nav button:hover {
  color: white;
  background: var(--nav-2);
}

.main {
  min-width: 0;
  padding: 24px;
}

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

.topbar h2 {
  margin: 0;
  font-size: 28px;
}

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

.grid.two {
  grid-template-columns: minmax(280px, 410px) 1fr;
}

.section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 8px 24px rgba(20, 31, 46, 0.05);
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.search {
  max-width: 360px;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(96px, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #eef2f6;
}

.segmented button {
  min-height: 38px;
  padding: 0 12px;
  color: #334155;
  background: transparent;
  font-weight: 900;
}

.segmented button.active {
  color: white;
  background: var(--accent);
}

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

.list-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: white;
  display: grid;
  gap: 7px;
}

.list-item.active {
  border-color: var(--accent);
  box-shadow: inset 4px 0 0 var(--accent);
}

.list-item button {
  text-align: left;
  background: transparent;
  color: inherit;
  padding: 0;
}

.client-period-status {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

.title-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.title-line strong {
  overflow-wrap: anywhere;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
  background: #e8edf3;
  color: #334155;
}

.badge.ok {
  background: #dcf5e6;
  color: var(--ok);
}

.badge.warn {
  background: #fff1d6;
  color: var(--warn);
}

.badge.bad {
  background: #ffe3e9;
  color: var(--accent-2);
}

.client-header {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.client-header h2 {
  margin: 0;
  font-size: 26px;
  overflow-wrap: anywhere;
}

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

.kv div {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.kv span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
  overflow-x: auto;
}

.tabs button {
  background: transparent;
  color: var(--muted);
  padding: 10px 8px;
  border-bottom: 3px solid transparent;
  font-weight: 900;
  white-space: nowrap;
}

.tabs button.active {
  color: var(--accent);
  border-color: var(--accent);
}

.tax-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.tax-tile {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.tax-tile label {
  display: flex;
  gap: 8px;
  align-items: center;
}

.tax-tile input[type="checkbox"] {
  width: 18px;
  height: 18px;
  padding: 0;
}

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

.tax-send-row {
  display: grid;
  grid-template-columns: 150px minmax(120px, 1fr) minmax(140px, 1fr);
  gap: 10px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: white;
}

.tax-check {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 40px;
}

.tax-check input {
  width: 18px;
  height: 18px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.overdue-row td {
  background: #fff7f8;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
  background: white;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  background: #eef2f6;
  color: #334155;
  font-size: 12px;
  text-transform: uppercase;
}

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

.compact-form {
  margin: 16px 0;
}

.task-checklist {
  gap: 8px;
}

.task-checklist > span {
  font-size: 13px;
  font-weight: 800;
}

.task-check {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(160px, 220px);
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfdff;
}

.task-check span {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
}

.task-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

.send-kind {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.send-kind > span {
  font-size: 13px;
  font-weight: 800;
}

.send-kind label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
}

.send-kind input {
  width: 18px;
  height: 18px;
}

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

.notice {
  border: 1px solid #f1d092;
  background: #fff8e8;
  color: #714c07;
  border-radius: 8px;
  padding: 12px;
  margin: 12px 0;
  font-size: 13px;
  line-height: 1.45;
}

.bad-notice {
  border-color: #f1b8c4;
  background: #fff2f5;
  color: #8a2640;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.42);
}

.modal {
  width: min(780px, 100%);
  max-height: min(860px, calc(100vh - 40px));
  overflow: auto;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.preview-modal {
  display: grid;
  gap: 14px;
}

.message-preview {
  margin: 0;
  padding: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  line-height: 1.45;
}

.preview-attachments {
  display: grid;
  gap: 6px;
}

.empty {
  border: 1px dashed #b8c2d0;
  border-radius: 8px;
  padding: 28px;
  text-align: center;
  color: var(--muted);
  background: white;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  max-width: min(420px, calc(100vw - 36px));
  background: var(--ink);
  color: white;
  border-radius: 8px;
  padding: 13px 15px;
  box-shadow: var(--shadow);
}

@media (max-width: 980px) {
  .app-shell,
  .login-panel,
  .grid.two {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .brand-pane {
    min-height: auto;
  }

  .tax-grid,
  .tax-send-row,
  .split-form,
  .task-check,
  .kv {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .main,
  .sidebar,
  .login-form,
  .brand-pane {
    padding: 18px;
  }

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

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