:root {
  --bg: #f7f2e9;
  --paper: #fffaf2;
  --panel: #fffdf8;
  --ink: #2d2923;
  --muted: #7a7166;
  --line: #eadfce;
  --primary: #246a5d;
  --primary-dark: #184d43;
  --accent: #c47b36;
  --soft: #eef6f2;
  --danger: #a14032;
  --shadow: 0 18px 50px rgba(60, 42, 20, 0.09);
  --radius: 22px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 5% 5%, rgba(196, 123, 54, 0.12), transparent 28rem),
    radial-gradient(circle at 95% 0%, rgba(36, 106, 93, 0.12), transparent 26rem),
    var(--bg);
}

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

button {
  cursor: pointer;
  touch-action: manipulation;
}

.hidden {
  display: none !important;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(460px, 100%);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(255, 253, 248, 0.94);
  box-shadow: var(--shadow);
}

.login-logo {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
  margin: 0 auto 10px;
}

.login-error {
  margin: -4px 0 0;
  padding: 10px 12px;
  border: 1px solid #f2c8be;
  border-radius: 12px;
  color: var(--danger);
  background: #fff2ef;
  font-size: 13px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  font-weight: 750;
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

h1 {
  margin: 18px 0 10px;
  font-size: clamp(32px, 6vw, 46px);
  line-height: 1;
}

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

h3 {
  margin-bottom: 4px;
  font-size: 19px;
}

h4 {
  margin-bottom: 8px;
}

.muted {
  color: var(--muted);
  line-height: 1.55;
}

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

.stack-form {
  display: grid;
  gap: 16px;
  margin-top: 26px;
}

label {
  display: grid;
  gap: 7px;
  color: #554d43;
  font-size: 13px;
  font-weight: 680;
}

input,
select,
textarea {
  min-height: 44px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 13px;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(36, 106, 93, 0.55);
  box-shadow: 0 0 0 4px rgba(36, 106, 93, 0.11);
}

textarea {
  resize: vertical;
}

.primary-btn,
.ghost-btn {
  min-height: 44px;
  border: 0;
  border-radius: 15px;
  padding: 11px 16px;
  font-weight: 800;
}

.primary-btn {
  color: white;
  background: var(--primary);
}

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

.ghost-btn {
  color: var(--primary-dark);
  border: 1px solid var(--line);
  background: #fff;
}

.ghost-btn:hover {
  background: var(--soft);
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: rgba(255, 250, 242, 0.88);
  backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.dashboard-logo {
  width: 54px;
  height: 54px;
  flex: 0 0 auto;
  display: block;
  object-fit: contain;
  border-radius: 14px;
}

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

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

.nav-menu button {
  text-align: left;
  border: 1px solid transparent;
  border-radius: 15px;
  padding: 12px 14px;
  color: #554d43;
  background: transparent;
  font-weight: 760;
}

.nav-menu button.active,
.nav-menu button:hover {
  color: var(--primary-dark);
  background: var(--soft);
  border-color: rgba(36, 106, 93, 0.12);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.sidebar-footer p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

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

.mobile-header,
.sidebar-backdrop,
.close-menu {
  display: none;
}

.menu-icon {
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 12px;
  color: white;
  background: var(--primary);
  font-size: 24px;
}

.mobile-brand {
  display: flex;
  align-items: center;
  gap: 9px;
}

.mobile-brand img {
  width: 38px;
  height: 38px;
  object-fit: contain;
  border-radius: 10px;
}

.mobile-brand strong,
.mobile-brand small {
  display: block;
}

.mobile-brand small {
  margin-top: 1px;
  color: var(--muted);
  font-size: 11px;
}

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

.toolbar {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.inline-field {
  min-width: 175px;
}

.notice {
  margin-bottom: 16px;
  padding: 13px 15px;
  border-radius: 16px;
  border: 1px solid rgba(36, 106, 93, 0.18);
  color: var(--primary-dark);
  background: var(--soft);
}

.notice.error {
  color: var(--danger);
  background: #fff2ef;
  border-color: #f2c8be;
}

.view {
  display: none;
}

.active-view {
  display: block;
}

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

.metric-card,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.88);
  box-shadow: 0 10px 28px rgba(60, 42, 20, 0.05);
}

.metric-card {
  padding: 18px;
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric-card strong {
  display: block;
  margin-top: 9px;
  font-size: 24px;
  line-height: 1.2;
}

.metric-card em {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.panel {
  padding: 20px;
  margin-bottom: 16px;
}

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

.two-col {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 24px;
}

.soft-tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 10px;
  border-radius: 999px;
  color: var(--primary-dark);
  background: var(--soft);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status-list,
.bar-list,
.record-list {
  display: grid;
  gap: 10px;
}

.status-item,
.record-item {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}

.status-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
}

.status-item strong,
.record-item strong {
  display: block;
  margin-bottom: 3px;
}

.status-item span,
.record-item span {
  color: var(--muted);
  font-size: 13px;
}

.status-badge {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 850;
  background: var(--soft);
  color: var(--primary-dark);
}

.status-badge.warn {
  color: #7c4d08;
  background: #fff3d2;
}

.status-badge.danger {
  color: #8d2d1f;
  background: #ffe7e2;
}

.bar-row {
  display: grid;
  gap: 7px;
}

.bar-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.bar-track {
  overflow: hidden;
  height: 11px;
  border-radius: 999px;
  background: #f1e6d6;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}

.form-panel {
  overflow: visible;
}

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

.compact-form {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.wide-field {
  grid-column: 1 / -1;
}

.table-wrap {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

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

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.money-pos {
  color: var(--primary-dark);
  font-weight: 800;
}

.money-neg {
  color: var(--danger);
  font-weight: 800;
}

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

.small-btn {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 9px;
  background: #fff;
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 800;
}

.report-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.report-box {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: #fff;
}

.report-box span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.report-box strong {
  display: block;
  margin-top: 6px;
  font-size: 20px;
}

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

.attachment-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  background: #fff;
}

.attachment-preview {
  height: 160px;
  display: grid;
  place-items: center;
  background: #f4eadb;
}

.attachment-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.attachment-body {
  padding: 13px;
}

.attachment-body a {
  color: var(--primary-dark);
  font-weight: 800;
  text-decoration: none;
}

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

.sop-grid article {
  border: 1px solid var(--line);
  border-radius: 17px;
  padding: 15px;
  background: #fff;
}

.sop-grid p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.checklist {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.check-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}

.check-dot {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: #fff;
  background: var(--primary);
  font-size: 13px;
  font-weight: 900;
}

.check-dot.off {
  background: #b69d83;
}

code {
  padding: 2px 6px;
  border-radius: 8px;
  color: var(--primary-dark);
  background: var(--soft);
}

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

  body.menu-open {
    overflow: hidden;
  }

  .sidebar {
    position: fixed;
    z-index: 70;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(320px, 86vw);
    height: 100dvh;
    overflow-y: auto;
    border-right: 1px solid var(--line);
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: 18px 0 50px rgba(60, 42, 20, 0.2);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    position: fixed;
    z-index: 60;
    inset: 0;
    display: block;
    background: rgba(45, 41, 35, 0.48);
  }

  .close-menu {
    display: grid;
    flex: 0 0 auto;
  }

  .mobile-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: -26px -26px 20px;
    padding: 12px 16px;
    position: sticky;
    top: 0;
    z-index: 40;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 253, 248, 0.96);
    backdrop-filter: blur(12px);
  }

  .nav-menu {
    grid-template-columns: 1fr;
  }

  .nav-menu button {
    min-height: 46px;
  }

  .cards-grid,
  .sop-grid,
  .attachment-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .transaction-form,
  .compact-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .two-col {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .sidebar {
    padding: 16px;
  }

  .main-area {
    padding: 16px;
  }

  .mobile-header {
    margin: -16px -16px 16px;
  }

  .login-page {
    padding: 14px;
    align-items: start;
  }

  .login-card {
    margin-top: 18px;
    padding: 22px 18px;
    border-radius: 20px;
  }

  .login-logo {
    margin-bottom: 4px;
  }

  h1 {
    font-size: 32px;
  }

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

  .toolbar {
    align-items: stretch;
  }

  .inline-field {
    width: 100%;
  }

  .nav-menu,
  .cards-grid,
  .report-summary,
  .sop-grid,
  .attachment-grid,
  .transaction-form,
  .compact-form {
    grid-template-columns: 1fr;
  }

  .panel-head {
    flex-direction: column;
  }

  .panel {
    padding: 16px;
    border-radius: 17px;
  }

  .metric-card strong {
    overflow-wrap: anywhere;
    font-size: clamp(20px, 7vw, 24px);
  }

  .table-wrap {
    margin-inline: -16px;
    padding-inline: 16px;
  }

  .action-row .small-btn,
  .panel-head .ghost-btn {
    min-height: 42px;
  }

  .status-item {
    grid-template-columns: 1fr;
  }

  .status-badge {
    width: fit-content;
  }
}
