:root {
  --bg: #f3f7f5;
  --surface: #ffffff;
  --surface-soft: #f8fbfa;
  --ink: #17231f;
  --muted: #66746f;
  --line: #dfe8e4;
  --brand: #14966a;
  --brand-dark: #123c33;
  --brand-soft: #e8f8f1;
  --blue: #3578e5;
  --amber: #d98a09;
  --red: #d84545;
  --violet: #7c5ce2;
  --shadow: 0 10px 30px rgba(20, 55, 44, 0.08);
  --radius: 18px;
  font-family: Tahoma, "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100vh; background: var(--bg); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.danger-text { color: var(--red); }
.nowrap { white-space: nowrap; }

.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 460px) 1fr;
  background: var(--surface);
}
.login-panel { display: grid; align-content: center; padding: clamp(28px, 7vw, 84px); }
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 42px; }
.brand-mark {
  width: 48px; height: 48px; border-radius: 15px; display: grid; place-items: center;
  background: linear-gradient(145deg, #26bd88, #0e7a56); color: white; font-size: 24px;
  box-shadow: 0 12px 24px rgba(20, 150, 106, .24);
}
.login-brand h1, .brand-copy strong { margin: 0; font-size: 22px; }
.login-brand p, .brand-copy small { display: block; margin: 4px 0 0; color: var(--muted); }
.login-panel > h2 { margin: 0 0 8px; font-size: 30px; }
.login-panel > p { margin: 0 0 28px; color: var(--muted); }
.login-form { display: grid; gap: 18px; }
.login-visual {
  min-height: 100vh; display: grid; align-content: end; padding: 70px;
  background:
    radial-gradient(circle at 20% 20%, rgba(72, 217, 165, .28), transparent 32%),
    linear-gradient(145deg, #0d2b25, #174f42 58%, #116446);
  color: white; overflow: hidden; position: relative;
}
.login-visual::before, .login-visual::after {
  content: ""; position: absolute; border: 1px solid rgba(255,255,255,.12); border-radius: 50%;
}
.login-visual::before { width: 520px; height: 520px; top: -180px; left: -100px; }
.login-visual::after { width: 320px; height: 320px; top: -80px; left: 0; }
.login-visual h2 { max-width: 650px; font-size: clamp(38px, 5vw, 70px); line-height: 1.18; margin: 0 0 20px; }
.login-visual p { max-width: 620px; font-size: 19px; color: #d4eee5; line-height: 1.8; }
.login-foot { margin-top: 30px; color: var(--muted); font-size: 12px; }

.field { display: grid; gap: 8px; }
.field label { font-size: 13px; font-weight: 700; color: #3f504a; }
.field input, .field select, .field textarea, .search-box input {
  width: 100%; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 12px; min-height: 46px; padding: 10px 13px; outline: none;
  transition: border-color .18s, box-shadow .18s;
}
.field textarea { min-height: 105px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .search-box input:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px rgba(20, 150, 106, .12);
}
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field-row.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.btn {
  border: 1px solid transparent; border-radius: 12px; min-height: 43px; padding: 9px 15px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700;
  color: var(--ink); background: var(--surface); transition: transform .15s, background .15s, border-color .15s;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { cursor: not-allowed; opacity: .55; transform: none; }
.btn-primary { color: white; background: var(--brand); }
.btn-primary:hover { background: #0f805a; }
.btn-dark { color: white; background: var(--brand-dark); }
.btn-outline { border-color: var(--line); }
.btn-soft { color: #087a54; background: var(--brand-soft); }
.btn-danger { color: white; background: var(--red); }
.btn-danger-soft { color: var(--red); background: #ffeded; }
.btn-block { width: 100%; }
.icon-btn {
  width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 11px;
  background: var(--surface); display: grid; place-items: center; color: var(--ink);
}

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 250px minmax(0, 1fr); }
.sidebar {
  position: sticky; top: 0; height: 100vh; background: #fff; border-left: 1px solid var(--line);
  display: flex; flex-direction: column; z-index: 30;
}
.brand { padding: 23px 20px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: center; }
.brand .brand-mark { width: 42px; height: 42px; font-size: 20px; box-shadow: none; }
.nav { display: grid; gap: 6px; padding: 20px 14px; }
.nav-section { color: #9aa5a1; font-size: 11px; padding: 18px 12px 5px; }
.nav-button {
  border: 0; background: transparent; color: #53615c; border-radius: 12px; min-height: 46px;
  padding: 10px 13px; display: flex; align-items: center; gap: 12px; text-align: right;
}
.nav-button:hover { background: var(--surface-soft); color: var(--ink); }
.nav-button.active { background: var(--brand-soft); color: #087653; font-weight: 700; }
.nav-icon { width: 24px; text-align: center; font-size: 18px; }
.sidebar-user { margin-top: auto; padding: 15px; border-top: 1px solid var(--line); }
.user-card { display: flex; gap: 10px; align-items: center; padding: 10px; border-radius: 12px; background: var(--surface-soft); }
.avatar { flex: 0 0 auto; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; background: var(--brand); color: white; font-weight: 800; }
.user-card strong { display: block; font-size: 13px; }
.user-card small { color: var(--muted); }
.user-card .icon-btn { margin-right: auto; width: 34px; height: 34px; background: transparent; }

.content-shell { min-width: 0; }
.mobile-header { display: none; }
.main-content { padding: 30px clamp(18px, 3vw, 42px) 50px; max-width: 1580px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
.page-head h1 { margin: 0 0 7px; font-size: clamp(25px, 3vw, 34px); }
.page-head p { margin: 0; color: var(--muted); }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.card { background: var(--surface); border: 1px solid #e8efec; border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { padding: 20px 22px 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-head h2, .card-head h3 { margin: 0; font-size: 18px; }
.card-body { padding: 22px; }
.kpi-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi-card { padding: 20px; min-height: 132px; display: flex; flex-direction: column; justify-content: space-between; }
.kpi-label { color: var(--muted); font-size: 13px; }
.kpi-value { font-size: 34px; line-height: 1; font-weight: 800; }
.kpi-foot { font-size: 12px; color: var(--muted); }
.kpi-icon { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; }
.kpi-card.blue .kpi-icon { color: var(--blue); background: #edf4ff; }
.kpi-card.amber .kpi-icon { color: var(--amber); background: #fff6e5; }
.kpi-card.red .kpi-icon { color: var(--red); background: #ffeded; }

.dashboard-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.dashboard-grid .span-2 { grid-column: span 2; }
.bar-list { display: grid; gap: 15px; }
.bar-row { display: grid; grid-template-columns: minmax(110px, 180px) 1fr 36px; align-items: center; gap: 12px; }
.bar-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.bar-track { height: 12px; border-radius: 99px; background: #eef2f0; overflow: hidden; }
.bar-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, #1cba83, #168f66); min-width: 2px; }
.bar-fill.blue { background: var(--blue); }
.bar-fill.amber { background: var(--amber); }
.bar-fill.red { background: var(--red); }
.bar-fill.violet { background: var(--violet); }
.bar-value { font-weight: 800; text-align: left; }
.alert-list { display: grid; gap: 10px; }
.alert-item { padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-radius: 13px; background: #fff7e8; color: #835200; }
.alert-item.danger { background: #ffeded; color: #9e2929; }
.alert-count { min-width: 34px; height: 28px; padding: 3px 10px; display: grid; place-items: center; border-radius: 99px; background: rgba(255,255,255,.7); font-weight: 800; }

.toolbar { padding: 16px; margin-bottom: 18px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.search-box { position: relative; flex: 1 1 260px; }
.search-box input { padding-right: 42px; }
.search-box::before { content: "⌕"; position: absolute; right: 15px; top: 9px; color: var(--muted); font-size: 23px; }
.filter-panel { padding: 18px; margin-bottom: 18px; }
.filter-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.result-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 15px 2px; color: var(--muted); }

.table-wrap { overflow: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th { padding: 14px 16px; background: #f7faf9; color: #63726c; font-size: 12px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
td { padding: 15px 16px; border-bottom: 1px solid #edf2f0; font-size: 13px; vertical-align: middle; }
tbody tr:hover { background: #fbfdfc; }
tbody tr:last-child td { border-bottom: 0; }
.table-link { border: 0; background: none; padding: 0; color: #096e50; font-weight: 800; }
.table-actions { display: flex; gap: 6px; justify-content: flex-end; }
.table-actions .icon-btn { width: 34px; height: 34px; }
.badge { display: inline-flex; align-items: center; min-height: 27px; padding: 4px 10px; border-radius: 99px; background: #edf2f0; color: #4a5b54; font-size: 11px; font-weight: 700; white-space: nowrap; }
.badge.completed { color: #087653; background: #e5f8f0; }
.badge.progress { color: #2464c7; background: #eaf2ff; }
.badge.waiting { color: #a06100; background: #fff3dd; }
.badge.issue { color: #ad3636; background: #ffebeb; }
.badge.violet { color: #6e4cc7; background: #f0eaff; }
.pagination { display: flex; justify-content: center; gap: 7px; margin-top: 18px; }
.pagination button { min-width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 10px; background: white; }
.pagination button.active { color: white; border-color: var(--brand); background: var(--brand); }
.empty { padding: 56px 20px; text-align: center; color: var(--muted); }
.empty-icon { width: 60px; height: 60px; margin: 0 auto 14px; display: grid; place-items: center; border-radius: 18px; background: var(--surface-soft); font-size: 28px; }

.order-cards { display: none; gap: 12px; }
.order-card { padding: 17px; }
.order-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.order-card h3 { margin: 0 0 5px; font-size: 17px; }
.order-card p { margin: 0; color: var(--muted); font-size: 12px; }
.order-card-select { display: inline-flex; align-items: center; gap: 7px; margin-bottom: 9px; color: var(--brand); font-size: 12px; font-weight: 800; }
.order-card-grid { margin-top: 15px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; font-size: 12px; }
.order-card-actions { margin-top: 15px; display: flex; gap: 8px; }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(260px, .7fr); gap: 18px; }
.detail-main { display: grid; gap: 18px; }
.info-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.info-item { padding: 15px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-soft); }
.info-item span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 11px; }
.info-item strong { font-size: 14px; }
.attachment-type-options { display: flex; flex-wrap: wrap; gap: 10px; }
.attachment-type-options label { min-width: 130px; padding: 13px 15px; display: inline-flex; align-items: center; gap: 9px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); font-weight: 800; }
.bulk-warning { margin: 18px 0 0; padding: 13px 15px; border-radius: 12px; color: #8b5900; background: #fff5df; font-size: 12px; }
.notes-box { padding: 17px; border-radius: 13px; background: #f7faf9; white-space: pre-wrap; line-height: 1.8; }
.media-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.media-item { position: relative; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: #eef3f1; }
.media-item img, .media-item video { display: block; width: 100%; aspect-ratio: 4/3; object-fit: cover; background: #111; }
.media-meta { padding: 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; background: white; }
.media-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.media-meta .icon-btn { width: 31px; height: 31px; }
.upload-zone { border: 2px dashed #b9cdc4; border-radius: 15px; padding: 25px; text-align: center; background: #fbfdfc; transition: .18s; }
.upload-zone.dragover { border-color: var(--brand); background: var(--brand-soft); }
.upload-zone input { display: none; }
.upload-zone strong { display: block; margin: 8px 0 4px; }
.upload-zone small { color: var(--muted); }
.upload-progress { height: 8px; border-radius: 99px; margin-top: 12px; overflow: hidden; background: #e9efec; }
.upload-progress > span { display: block; width: 0; height: 100%; background: var(--brand); transition: width .2s; }
.invoice-list, .timeline { display: grid; gap: 10px; }
.invoice-row { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.invoice-row .file-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: #ffeded; color: var(--red); }
.invoice-copy { min-width: 0; flex: 1; }
.invoice-copy strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.invoice-copy small { color: var(--muted); }
.timeline-item { position: relative; padding: 0 25px 16px 0; border-right: 2px solid #d8e7e1; }
.timeline-item::before { content: ""; position: absolute; right: -6px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); }
.timeline-item strong { display: block; font-size: 12px; }
.timeline-item small { color: var(--muted); }
.timeline-changes { margin-top: 6px; padding: 8px; border-radius: 8px; background: #f7faf9; font-size: 11px; line-height: 1.7; }

.modal-backdrop { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 20px; background: rgba(10, 28, 23, .56); backdrop-filter: blur(3px); }
.modal { width: min(760px, 100%); max-height: calc(100vh - 40px); overflow: auto; background: white; border-radius: 20px; box-shadow: 0 24px 80px rgba(0,0,0,.2); }
.modal.small { width: min(470px, 100%); }
.modal-head { position: sticky; top: 0; z-index: 2; padding: 19px 22px; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: white; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 19px; }
.modal-body { padding: 22px; }
.modal-foot { position: sticky; bottom: 0; padding: 16px 22px; display: flex; justify-content: flex-end; gap: 9px; background: white; border-top: 1px solid var(--line); }

.toast-root { position: fixed; z-index: 120; left: 22px; bottom: 22px; display: grid; gap: 9px; }
.toast { min-width: 280px; max-width: 440px; padding: 14px 16px; border-radius: 13px; color: white; background: var(--brand-dark); box-shadow: var(--shadow); animation: toast-in .2s ease-out; }
.toast.error { background: #9b2e2e; }
.toast.success { background: #087653; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }
.skeleton { min-height: 120px; border-radius: var(--radius); background: linear-gradient(90deg, #eef3f1 20%, #f8faf9 40%, #eef3f1 60%); background-size: 300% 100%; animation: pulse 1.2s infinite; }
@keyframes pulse { to { background-position: -100% 0; } }

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

@media (max-width: 820px) {
  .login-page { grid-template-columns: 1fr; }
  .login-visual { display: none; }
  .login-panel { min-height: 100vh; padding: 32px 24px; }
  .app-shell { display: block; }
  .sidebar { position: fixed; right: 0; width: 270px; transform: translateX(102%); transition: transform .22s; box-shadow: -12px 0 40px rgba(0,0,0,.12); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 25; background: rgba(0,0,0,.3); }
  .mobile-header { height: 67px; padding: 10px 15px; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: white; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
  .mobile-brand { display: flex; align-items: center; gap: 9px; font-weight: 800; }
  .mobile-brand .brand-mark { width: 37px; height: 37px; font-size: 17px; border-radius: 11px; }
  .main-content { padding: 21px 14px 38px; }
  .page-head { align-items: stretch; flex-direction: column; }
  .page-actions .btn { flex: 1; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-grid .span-2 { grid-column: span 1; }
  .desktop-table { display: none; }
  .order-cards { display: grid; }
  .detail-grid { grid-template-columns: 1fr; }
  .info-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field-row.three { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 540px) {
  .page-head h1 { font-size: 26px; }
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi-card { min-height: 112px; }
  .filter-grid, .field-row, .field-row.three, .info-grid { grid-template-columns: 1fr; }
  .toolbar .btn { flex: 1 1 auto; }
  .media-grid { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 100px 1fr 30px; gap: 8px; }
  .modal-backdrop { align-items: end; padding: 0; }
  .modal, .modal.small { width: 100%; max-height: 94vh; border-radius: 20px 20px 0 0; }
  .toast-root { left: 12px; right: 12px; bottom: 12px; }
  .toast { min-width: 0; width: 100%; }
}

@media print {
  .sidebar, .mobile-header, .page-actions, .toolbar, .table-actions { display: none !important; }
  .app-shell { display: block; }
  .main-content { padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
}
