:root {
  --ink: #17211f;
  --muted: #66736f;
  --line: #dde5e1;
  --paper: #f5f7f4;
  --card: #ffffff;
  --forest: #12332f;
  --forest-2: #1c4942;
  --green: #2f7d68;
  --mint: #dff1e9;
  --amber: #c77a22;
  --amber-bg: #fff0d8;
  --red: #b64d45;
  --red-bg: #fde8e6;
  --blue: #446b8f;
  --shadow: 0 16px 50px rgba(25, 55, 48, .08);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; background: var(--paper); }
body { margin: 0; color: var(--ink); background: var(--paper); font-family: "Noto Sans SC", -apple-system, BlinkMacSystemFont, sans-serif; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 34px; background: radial-gradient(circle at 15% 15%, rgba(133,203,176,.2), transparent 34%), linear-gradient(145deg, #0c2925, #153f38 58%, #0b2723); }
.login-panel { width: min(920px, 100%); min-height: 560px; display: grid; grid-template-columns: 1.15fr .85fr; grid-template-rows: auto 1fr; gap: 24px 46px; padding: 38px 42px; border: 1px solid rgba(255,255,255,.14); border-radius: 26px; color: #fff; background: rgba(255,255,255,.075); box-shadow: 0 35px 100px rgba(0,0,0,.28); backdrop-filter: blur(18px); }
.login-brand { grid-column: 1 / -1; display: flex; align-items: center; gap: 13px; }
.login-brand strong, .login-brand span { display: block; }
.login-brand strong { font-size: 17px; }
.login-brand span { margin-top: 3px; color: #a9c8bd; font-size: 11px; }
.login-copy { align-self: center; }
.login-kicker { color: #97cdb8; font-size: 10px; font-weight: 700; letter-spacing: 2px; }
.login-copy h1 { margin: 15px 0 16px; font-size: clamp(30px, 4vw, 46px); line-height: 1.25; letter-spacing: -1.6px; }
.login-copy p { max-width: 390px; margin: 0; color: #b5cec5; font-size: 13px; line-height: 1.8; }
.login-form { align-self: center; display: grid; gap: 15px; padding: 27px; border-radius: 18px; color: var(--ink); background: rgba(255,255,255,.97); box-shadow: 0 22px 60px rgba(0,0,0,.18); }
.login-form h2 { margin: 0; font-size: 21px; }
.login-form p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.login-form label { display: grid; gap: 7px; color: #53615c; font-size: 11px; font-weight: 600; }
.login-form input { width: 100%; height: 43px; padding: 0 12px; border: 1px solid #d5dfda; border-radius: 9px; outline: none; }
.login-form input:focus { border-color: #6ba58f; box-shadow: 0 0 0 3px rgba(65,132,108,.12); }
.login-button { width: 100%; min-height: 43px; margin-top: 3px; }
.login-form .login-error { margin: -2px 0 0; padding: 9px 10px; border-radius: 8px; color: #9c403a; background: #fde8e6; line-height: 1.5; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 244px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 28px 18px 20px; color: #edf6f2; background: linear-gradient(165deg, #153a35 0%, #102b28 62%, #0a211e 100%); }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 10px 26px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; color: var(--forest); background: #a8d8c5; font-weight: 800; letter-spacing: -.5px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.55); }
.brand strong, .brand span { display: block; }
.brand strong { font-size: 16px; letter-spacing: .5px; }
.brand span { margin-top: 2px; color: #9fb9b1; font-size: 11px; }
.nav { display: grid; gap: 5px; margin-top: 22px; }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 13px; border: 0; border-radius: 10px; color: #b9ccc6; background: transparent; text-align: left; transition: .18s ease; }
.nav-item span { width: 21px; color: #8fb8aa; font-size: 18px; line-height: 1; text-align: center; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav-item.active { color: #fff; background: rgba(135, 204, 177, .17); box-shadow: inset 3px 0 0 #83c8ae; }
.nav-item.active span { color: #a8dcc8; }
.sidebar-foot { margin-top: auto; display: flex; align-items: flex-start; gap: 10px; padding: 14px 12px; border: 1px solid rgba(255,255,255,.09); border-radius: 12px; background: rgba(255,255,255,.035); }
.sidebar-foot strong, .sidebar-foot small { display: block; }
.sidebar-foot strong { font-size: 12px; }
.sidebar-foot small { margin-top: 3px; color: #92aea5; font-size: 10px; line-height: 1.5; }
.live-dot { width: 8px; height: 8px; flex: 0 0 auto; margin-top: 5px; border-radius: 50%; background: #7ed6a9; box-shadow: 0 0 0 4px rgba(126,214,169,.12); }

.main { min-width: 0; }
.topbar { height: 104px; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 23px 34px 20px; border-bottom: 1px solid var(--line); background: rgba(250, 252, 249, .92); backdrop-filter: blur(12px); }
.eyebrow { margin: 0 0 3px; color: var(--green); font-size: 10px; font-weight: 700; letter-spacing: 1.8px; text-transform: uppercase; }
.topbar h1 { margin: 0; font-size: 23px; letter-spacing: -.4px; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.account-actions { display: flex; align-items: center; gap: 8px; }
.date-control { display: flex; align-items: center; gap: 9px; padding: 7px 10px 7px 13px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--muted); font-size: 11px; }
.date-control input { border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 12px; }
.user-chip { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; }
.user-chip b { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--green); font-size: 12px; }
.top-link { padding: 5px 7px; border: 0; color: var(--muted); background: transparent; font-size: 10px; }
.top-link:hover { color: var(--green); }

.page { padding: 28px 34px 52px; }
.loading, .empty { min-height: 240px; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--muted); }
.loading span { width: 28px; height: 28px; border: 3px solid #d9e8e2; border-top-color: var(--green); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.section-head h2 { margin: 0; font-size: 17px; }
.section-head p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.button-row { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 36px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: #fff; font-size: 12px; font-weight: 600; transition: .16s ease; }
.btn:hover { border-color: #b4c8c0; transform: translateY(-1px); }
.btn-primary { color: #fff; border-color: var(--green); background: var(--green); }
.btn-primary:hover { background: #276e5c; }
.btn-danger { color: var(--red); border-color: #efc9c5; background: #fff; }
.btn-small { min-height: 29px; padding: 5px 9px; font-size: 11px; }
.icon-btn { width: 34px; height: 34px; border: 0; border-radius: 9px; color: var(--muted); background: #f2f5f3; font-size: 21px; }

.kpi-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 13px; margin-bottom: 22px; }
.kpi-card { position: relative; overflow: hidden; min-height: 126px; padding: 18px; border: 1px solid #e2e9e5; border-radius: 15px; background: var(--card); box-shadow: 0 6px 24px rgba(24,58,49,.04); }
.kpi-card::after { content: ""; position: absolute; right: -18px; bottom: -22px; width: 78px; height: 78px; border-radius: 50%; background: var(--kpi-tint, #edf6f2); }
.kpi-label { color: var(--muted); font-size: 11px; }
.kpi-value { display: block; margin-top: 15px; font-size: 27px; line-height: 1; letter-spacing: -1px; }
.kpi-unit { margin-left: 4px; color: var(--muted); font-size: 11px; font-weight: 400; }
.kpi-note { display: block; margin-top: 10px; color: #7c8884; font-size: 10px; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(300px, .8fr); gap: 18px; }
.card { border: 1px solid #e2e9e5; border-radius: 15px; background: var(--card); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 19px 13px; border-bottom: 1px solid #edf1ef; }
.card-head h3 { margin: 0; font-size: 14px; }
.card-head span { color: var(--muted); font-size: 10px; }
.card-body { padding: 16px 19px 19px; }

.table-wrap { overflow: auto; border: 1px solid #e2e9e5; border-radius: 13px; background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: 11px; }
th { position: sticky; top: 0; z-index: 1; padding: 11px 12px; color: #5e6c67; background: #f5f8f6; font-weight: 600; text-align: left; white-space: nowrap; }
td { padding: 10px 12px; border-top: 1px solid #edf1ef; vertical-align: middle; }
tbody tr:hover { background: #fbfdfc; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.center { text-align: center; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.truncate { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status, .tag { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 99px; background: var(--mint); color: #276c59; font-size: 10px; font-weight: 600; white-space: nowrap; }
.status::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.status.warn { color: #9b5e18; background: var(--amber-bg); }
.status.danger { color: var(--red); background: var(--red-bg); }
.tag { background: #edf2f7; color: #526a81; }
.progress-bar { width: 100%; min-width: 90px; height: 6px; overflow: hidden; border-radius: 99px; background: #e7eeea; }
.progress-bar span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #3a8b72, #78bea2); }

.alert-list { display: grid; gap: 9px; }
.alert-item { padding: 12px; border: 1px solid #f0e1d0; border-radius: 11px; background: #fffbf4; }
.alert-item strong { display: block; font-size: 11px; }
.alert-item p { margin: 5px 0 0; color: var(--muted); font-size: 10px; line-height: 1.55; }
.alert-empty { padding: 28px 10px; color: var(--muted); text-align: center; font-size: 11px; }

.filter-bar { display: flex; align-items: end; gap: 10px; flex-wrap: wrap; margin-bottom: 15px; padding: 14px; border: 1px solid #e1e8e4; border-radius: 13px; background: #fbfcfb; }
.field { display: grid; gap: 6px; min-width: 150px; }
.field.grow { flex: 1; }
.field label { color: #56645f; font-size: 10px; font-weight: 600; }
.field input, .field select, .field textarea { width: 100%; min-height: 37px; padding: 8px 10px; border: 1px solid #d9e2dd; border-radius: 8px; outline: none; color: var(--ink); background: #fff; font-size: 12px; }
.field textarea { min-height: 78px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: #77aa98; box-shadow: 0 0 0 3px rgba(69,135,111,.1); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-section { grid-column: 1 / -1; margin: 5px 0 -2px; padding-top: 10px; border-top: 1px solid #edf1ef; color: var(--green); font-size: 11px; font-weight: 700; }
.form-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 18px; padding-top: 15px; border-top: 1px solid #edf1ef; }

.hero-search { padding: 25px; border-radius: 16px; color: #fff; background: linear-gradient(135deg, #1b4a42, #12332f); box-shadow: 0 18px 45px rgba(17,52,47,.16); }
.hero-search h2 { margin: 0; font-size: 19px; }
.hero-search p { margin: 7px 0 17px; color: #b9d1c8; font-size: 11px; }
.hero-search form { display: flex; gap: 9px; max-width: 680px; }
.hero-search input { flex: 1; min-width: 0; height: 42px; padding: 0 13px; border: 1px solid rgba(255,255,255,.2); border-radius: 9px; outline: none; background: rgba(255,255,255,.96); }
.hero-search .btn { min-width: 95px; border-color: #a7d8c4; background: #a7d8c4; color: #163e36; }
.result-space { margin-top: 18px; }
.summary-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 15px; }
.summary-box { padding: 15px 16px; border: 1px solid #e1e8e4; border-radius: 12px; background: #fff; }
.summary-box span { display: block; color: var(--muted); font-size: 10px; }
.summary-box strong { display: block; margin-top: 7px; font-size: 20px; }
.order-title { margin-bottom: 14px; }
.order-title h2 { margin: 0; font-size: 19px; }
.order-title p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }

.modal[hidden], .toast[hidden] { display: none; }
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 22px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(10,28,25,.54); backdrop-filter: blur(3px); }
.modal-card { position: relative; width: min(760px, 100%); max-height: calc(100vh - 44px); overflow: auto; border-radius: 16px; background: #fff; box-shadow: 0 28px 80px rgba(3,22,18,.28); }
.modal-card > header { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding: 18px 21px 14px; border-bottom: 1px solid #e8eeeb; background: rgba(255,255,255,.96); backdrop-filter: blur(8px); }
.modal-card h2 { margin: 0; font-size: 18px; }
#modal-form { padding: 20px 21px 22px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 80; max-width: 360px; padding: 12px 16px; border-radius: 10px; color: #fff; background: #244d43; box-shadow: 0 15px 45px rgba(0,0,0,.2); font-size: 12px; }
.toast.error { background: #9c403a; }

.entry-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 18px; align-items: start; }
.entry-card { padding: 21px; }
.entry-aside { padding: 18px; }
.entry-aside h3 { margin: 0 0 12px; font-size: 14px; }
.formula-note { padding: 13px; border-radius: 10px; background: #edf6f2; color: #365c51; font-size: 11px; line-height: 1.7; }
.formula-preview { display: grid; gap: 8px; margin-top: 12px; }
.formula-preview div { display: flex; justify-content: space-between; gap: 10px; padding-bottom: 8px; border-bottom: 1px solid #e7eeea; font-size: 11px; }
.formula-preview div:last-child { border-bottom: 0; }
.formula-preview span { color: var(--muted); }

.report-print { display: none; }
@media print {
  .sidebar, .topbar, .filter-bar, .button-row, .no-print { display: none !important; }
  .app-shell { display: block; }
  .page { padding: 0; }
  .table-wrap { overflow: visible; border: 0; }
  th { position: static; }
  .report-print { display: block; margin-bottom: 18px; }
}

@media (max-width: 1180px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dashboard-grid, .entry-layout { grid-template-columns: 1fr; }
  .entry-aside { order: -1; }
}
@media (max-width: 820px) {
  .login-panel { grid-template-columns: 1fr; padding: 28px; }
  .login-brand { grid-column: auto; }
  .login-copy h1 { font-size: 31px; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 15px; }
  .brand { padding-bottom: 14px; }
  .nav { display: flex; overflow-x: auto; margin-top: 14px; padding-bottom: 4px; }
  .nav-item { width: auto; flex: 0 0 auto; white-space: nowrap; }
  .sidebar-foot { display: none; }
  .topbar { height: auto; padding: 18px; align-items: flex-start; }
  .topbar-actions { align-items: flex-end; flex-direction: column-reverse; }
  .account-actions { flex-wrap: wrap; justify-content: flex-end; }
  .user-chip span { display: none; }
  .page { padding: 20px 18px 40px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
}
@media (max-width: 520px) {
  .topbar { gap: 10px; }
  .date-control span { display: none; }
  .kpi-grid, .summary-strip { grid-template-columns: 1fr; }
  .hero-search form { flex-direction: column; }
  .filter-bar { display: grid; grid-template-columns: 1fr; }
  .field { min-width: 0; }
}
