:root {
  --bg: #eef7ff;
  --panel: #ffffff;
  --soft-blue: #dff1ff;
  --blue: #2477d4;
  --blue-dark: #155ca8;
  --text: #18324a;
  --muted: #6c8298;
  --line: #d8e9f8;
  --danger: #d9534f;
  --success: #21875b;
  --shadow: 0 18px 45px rgba(31, 94, 154, 0.13);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, #ffffff 0, #eaf7ff 34%, #edf7ff 100%);
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px;
  background: rgba(255, 255, 255, 0.72);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

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

.brand-icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  color: #fff;
  background: linear-gradient(135deg, var(--blue), #5db9ff);
  font-weight: 800;
  box-shadow: var(--shadow);
}

.brand strong { display: block; font-size: 17px; }
.brand span { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; }

nav { display: grid; gap: 10px; }
nav a {
  color: var(--text);
  text-decoration: none;
  padding: 13px 14px;
  border-radius: 14px;
  font-weight: 700;
}
nav a:hover, nav a.active {
  color: var(--blue-dark);
  background: var(--soft-blue);
}

.main-content {
  padding: 28px;
  max-width: 1280px;
  width: 100%;
}

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

.eyebrow {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}

h1, h2, h3 { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 30px; }
h2 { font-size: 20px; }
h3 { font-size: 17px; }

.date-pill {
  padding: 11px 15px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 700;
}

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

.card {
  background: rgba(255,255,255,.9);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.stat {
  min-height: 138px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.stat span { color: var(--muted); font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.stat strong { display: block; font-size: 28px; margin-top: 10px; }
.stat small { color: var(--muted); }

form { display: grid; gap: 14px; }
.form-row { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 800; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 13px;
  background: #fafdff;
  color: var(--text);
  font: inherit;
  outline: none;
}
textarea { min-height: 82px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: #7dbef5; box-shadow: 0 0 0 4px rgba(36,119,212,.12); }

button, .btn {
  border: 0;
  padding: 12px 15px;
  border-radius: 14px;
  color: #fff;
  background: var(--blue);
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}
button:hover, .btn:hover { background: var(--blue-dark); }
.btn-soft { background: var(--soft-blue); color: var(--blue-dark); }
.btn-soft:hover { background: #cfeaff; }
.btn-danger { background: var(--danger); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 13px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
td strong { display: block; }

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
  background: var(--soft-blue);
  color: var(--blue-dark);
}
.badge.success { background: #e6f8ef; color: var(--success); }
.badge.danger { background: #ffecec; color: var(--danger); }
.badge.gray { background: #edf2f7; color: #60758a; }

.alert {
  margin-bottom: 18px;
  padding: 14px 16px;
  border-radius: 16px;
  font-weight: 700;
}
.alert.success { background: #e6f8ef; color: var(--success); border: 1px solid #bdebd5; }
.alert.error { background: #ffecec; color: var(--danger); border: 1px solid #ffd0d0; }

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

.helper { color: var(--muted); font-size: 13px; line-height: 1.5; }
.empty {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 18px;
  color: var(--muted);
  background: #fafdff;
}

@media (max-width: 920px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: relative;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  nav { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  nav a { text-align: center; font-size: 13px; padding: 11px 8px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 520px) {
  .main-content, .sidebar { padding: 18px; }
  nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  h1 { font-size: 25px; }
  .stat strong { font-size: 24px; }
}


/* Responsive patch v2 */
html {
  width: 100%;
  overflow-x: hidden;
}

body {
  width: 100%;
  overflow-x: hidden;
}

img, svg, video {
  max-width: 100%;
  height: auto;
}

.main-content {
  min-width: 0;
}

.card,
.stat,
.table-wrap,
form,
input,
select,
textarea,
button,
.btn {
  min-width: 0;
}

.table-wrap {
  width: 100%;
  border-radius: 18px;
}

.actions,
.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 920px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.94);
  }

  .brand {
    margin-bottom: 12px;
  }

  .brand-icon {
    width: 40px;
    height: 40px;
    border-radius: 14px;
  }

  nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: thin;
  }

  nav a {
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 10px 12px;
  }

  .main-content {
    max-width: none;
    padding: 18px;
  }

  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  .section-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .section-title .btn,
  .section-title button {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .topbar {
    gap: 12px;
    margin-bottom: 16px;
  }

  .date-pill {
    width: 100%;
    text-align: center;
  }

  .card {
    border-radius: 18px;
    padding: 16px;
  }

  .stat {
    min-height: 112px;
  }

  .stat strong {
    font-size: 23px;
    word-break: break-word;
  }

  h1 {
    font-size: 24px;
    line-height: 1.18;
  }

  h2 {
    font-size: 18px;
  }

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

  button,
  .btn {
    width: 100%;
  }

  .table-wrap {
    overflow: visible;
  }

  table.responsive-table,
  table.responsive-table thead,
  table.responsive-table tbody,
  table.responsive-table th,
  table.responsive-table td,
  table.responsive-table tr {
    display: block;
    width: 100%;
    min-width: 0 !important;
  }

  table.responsive-table {
    border-collapse: separate;
    border-spacing: 0 12px;
  }

  table.responsive-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  table.responsive-table tbody tr {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 10px 25px rgba(31, 94, 154, 0.08);
  }

  table.responsive-table td {
    display: grid;
    grid-template-columns: 118px 1fr;
    gap: 10px;
    align-items: start;
    padding: 9px 0;
    border-bottom: 1px solid #edf5fc;
    text-align: right;
  }

  table.responsive-table td:last-child {
    border-bottom: 0;
  }

  table.responsive-table td::before {
    content: attr(data-label);
    text-align: left;
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .05em;
  }

  table.responsive-table td strong,
  table.responsive-table td .helper {
    text-align: right;
  }
}

@media (max-width: 420px) {
  .main-content,
  .sidebar {
    padding-left: 14px;
    padding-right: 14px;
  }

  .brand strong {
    font-size: 15px;
  }

  .brand span {
    font-size: 11px;
  }

  table.responsive-table td {
    grid-template-columns: 95px 1fr;
    font-size: 14px;
  }
}
