:root {
  color-scheme: dark;
  font-family: Inter, "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  --ink: #eef3f7;
  --muted: #8fa0ae;
  --panel: #111d29;
  --panel-2: #162432;
  --line: #263746;
  --accent: #f5c542;
  --accent-deep: #dcae20;
  --cyan: #57d7dc;
  --danger: #ff7373;
  --shadow: 0 22px 70px rgba(0, 0, 0, .32);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: #09131d; }
body { min-height: 100vh; margin: 0; color: var(--ink); background: #09131d; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 0%, #183044 0%, #09131d 60%);
}

.login-brand {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100vh;
  padding: clamp(32px, 6vw, 80px);
  overflow: hidden;
}

.login-brand::after {
  content: "";
  position: absolute;
  width: min(52vw, 680px);
  aspect-ratio: 1;
  right: -20%;
  bottom: -26%;
  border: 1px solid rgba(245, 197, 66, .18);
  border-radius: 50%;
  box-shadow: 0 0 0 72px rgba(245,197,66,.025), 0 0 0 144px rgba(245,197,66,.02);
}

.brand-lockup, .side-brand { display: flex; align-items: center; gap: 13px; font-weight: 800; letter-spacing: .01em; }
.battery-mark { width: 46px; height: 30px; padding: 5px; border: 2px solid var(--accent); border-radius: 7px; position: relative; }
.battery-mark::after { content: ""; position: absolute; right: -6px; top: 8px; width: 4px; height: 10px; border-radius: 0 3px 3px 0; background: var(--accent); }
.battery-mark span { display: block; height: 100%; width: 72%; border-radius: 2px; background: linear-gradient(90deg, var(--accent-deep), var(--accent)); box-shadow: 0 0 18px rgba(245,197,66,.28); }
.brand-copy { max-width: 690px; position: relative; z-index: 1; }
.eyebrow { color: var(--accent); text-transform: uppercase; letter-spacing: .13em; font-weight: 800; font-size: .82rem; }
.brand-copy h1 { margin: 18px 0 22px; max-width: 640px; font-size: clamp(3rem, 7vw, 6.7rem); line-height: .96; letter-spacing: -.065em; }
.brand-copy p { max-width: 530px; margin: 0; color: #aebbc6; font-size: 1.08rem; line-height: 1.8; }
.brand-meta { display: flex; gap: 28px; color: #728695; font-size: .85rem; }

.login-panel { width: min(440px, 100%); color: #17202a; }
.auth-card { width: 100%; padding: clamp(26px, 5vw, 42px); border: 1px solid #d7dedb; border-radius: 20px; background: #eef1ec; box-shadow: 0 24px 70px rgba(0,0,0,.35); }
.auth-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 34px; color: #17202a; font-weight: 850; }
.auth-brand .battery-mark { width: 38px; height: 26px; padding: 4px; }
.auth-brand .battery-mark::after { top: 7px; height: 8px; }
.auth-card h2 { margin: 0 0 10px; font-size: clamp(2rem, 4vw, 3rem); letter-spacing: -.045em; }
.auth-card > p { margin: 0 0 34px; color: #65727d; line-height: 1.7; }
.remember-row { display: flex; align-items: center; gap: 10px; margin: -2px 0 8px; color: #43515b; font-weight: 750; cursor: pointer; }
.remember-row input { width: 19px; height: 19px; margin: 0; accent-color: #162330; }
.field { display: grid; gap: 9px; margin-bottom: 18px; }
.field label { font-size: .9rem; font-weight: 800; }
.field input, .field select, .field textarea, .month-control {
  width: 100%;
  border: 1px solid #ccd4d4;
  border-radius: 12px;
  background: #fff;
  color: #17202a;
  padding: 13px 14px;
  min-height: 48px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus, .month-control:focus { border-color: #9f7b00; box-shadow: 0 0 0 4px rgba(245,197,66,.2); }
.primary-button, .secondary-button, .ghost-button, .danger-button {
  border: 0;
  border-radius: 12px;
  min-height: 46px;
  padding: 0 18px;
  font-weight: 800;
}
.primary-button { width: 100%; background: #162330; color: #fff; box-shadow: 0 10px 24px rgba(22,35,48,.18); }
.primary-button:hover { background: #223647; }
.secondary-button { background: var(--accent); color: #1b1e18; }
.secondary-button:disabled { cursor: not-allowed; opacity: .45; }
.ghost-button { color: var(--ink); background: transparent; border: 1px solid var(--line); }
.danger-button { color: #fff; background: #9a3434; }
.form-error { min-height: 22px; color: #a72828; font-weight: 700; font-size: .9rem; margin: 8px 0 12px; }
.auth-note { margin-top: 26px; padding-top: 20px; border-top: 1px solid #d5dbd8; color: #6f7c85; font-size: .88rem; line-height: 1.65; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 244px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 26px 20px; border-right: 1px solid var(--line); background: #0c1721; display: flex; flex-direction: column; }
.mobile-menu-toggle { display:none; }
.side-brand { padding: 0 8px 28px; }
.side-brand > span { max-width: 145px; font-size: .9rem; line-height: 1.35; }
.side-brand .battery-mark { width: 34px; height: 23px; padding: 4px; border-width: 2px; }
.side-brand .battery-mark::after { top: 6px; height: 8px; }
.nav-label { margin: 20px 10px 8px; color: #607381; font-size: .74rem; font-weight: 800; text-transform: uppercase; letter-spacing: .12em; }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 46px; padding: 0 13px; margin: 3px 0; border: 0; border-radius: 11px; background: transparent; color: #8ea0ad; text-align: left; font-weight: 700; }
.nav-item.active { background: rgba(245,197,66,.12); color: #fff4c5; }
.nav-item.disabled { opacity: .38; cursor: default; }
.nav-icon { width: 9px; height: 9px; border: 2px solid currentColor; border-radius: 3px; }
.sidebar-footer { margin-top: auto; padding: 16px 8px 0; border-top: 1px solid var(--line); }
.user-name { font-weight: 800; }
.user-role { color: var(--muted); font-size: .8rem; margin-top: 3px; }
.logout-link { margin-top: 14px; padding: 0; border: 0; background: transparent; color: #9fb1be; font-weight: 700; }

.main-area { min-width: 0; background: #0c1620; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 24px clamp(20px, 4vw, 48px); border-bottom: 1px solid var(--line); background: rgba(12,22,32,.92); backdrop-filter: blur(14px); }
.topbar h1 { margin: 0; font-size: clamp(1.5rem, 3vw, 2.25rem); letter-spacing: -.04em; }
.topbar p { margin: 5px 0 0; color: var(--muted); font-size: .9rem; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.month-control { width: auto; min-width: 150px; background: var(--panel); color: var(--ink); border-color: var(--line); }
.top-logout-button { white-space: nowrap; }
.content { padding: clamp(20px, 4vw, 48px); }
.year-dashboard { margin-bottom: 22px; padding: clamp(20px, 3vw, 30px); border: 1px solid #354652; border-radius: 18px; background: linear-gradient(135deg, #152532, #101b25 68%); box-shadow: var(--shadow); overflow: hidden; }
.year-dashboard-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.year-dashboard h2 { margin: 6px 0 4px; font-size: clamp(1.35rem, 3vw, 2rem); letter-spacing: -.035em; }
.year-dashboard p { margin: 0; color: var(--muted); font-size: .86rem; }
.year-metrics { display: grid; grid-template-columns: repeat(3, minmax(112px, 1fr)); gap: 10px; }
.year-metrics > div { min-width: 118px; padding: 13px 15px; border: 1px solid #304353; border-radius: 12px; background: rgba(7,16,24,.34); }
.year-metrics span { display: block; margin-bottom: 5px; color: var(--muted); font-size: .75rem; font-weight: 700; }
.year-metrics strong { font-size: 1.13rem; font-variant-numeric: tabular-nums; }
.growth-metric.positive strong { color: #8ce4b2; }
.growth-metric.negative strong { color: #ff9292; }
.growth-metric.neutral strong { color: #d4dde3; font-size: .9rem; }
.year-chart-wrap { margin-top: 18px; overflow-x: auto; }
.year-chart { display: block; width: 100%; min-width: 660px; height: 180px; }
.year-chart text { fill: #91a4b1; font-size: 12px; font-family: inherit; }
.chart-legend { display: flex; justify-content: flex-end; gap: 18px; color: var(--muted); font-size: .76rem; }
.chart-legend span::before { content: ""; display: inline-block; width: 9px; height: 9px; margin-right: 6px; border-radius: 3px; }
.legend-current::before { background: var(--accent); }
.legend-previous::before { background: #405668; }
.summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
.summary-card { padding: 20px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); }
.summary-label { color: var(--muted); font-size: .84rem; font-weight: 700; }
.summary-value { margin-top: 9px; font-size: clamp(1.7rem, 4vw, 2.5rem); font-weight: 850; letter-spacing: -.04em; }
.summary-card.accent { background: linear-gradient(145deg, #e7bb32, #f5d36b); color: #1c221c; border-color: transparent; }
.summary-card.accent .summary-label { color: #604d0d; }
.hours-breakdown { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 15px; padding-top: 13px; border-top: 1px solid rgba(63,50,8,.22); }
.hours-breakdown div { display: grid; gap: 3px; }
.hours-breakdown span { color: #6a540e; font-size: .72rem; font-weight: 750; }
.hours-breakdown strong { font-size: .94rem; font-variant-numeric: tabular-nums; }
.workspace-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-items: start; }
.panel { border: 1px solid var(--line); border-radius: 17px; background: var(--panel); overflow: hidden; box-shadow: var(--shadow); }
.panel-header { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.panel-title { margin: 0; font-size: 1.04rem; }
.panel-meta { color: var(--muted); font-size: .84rem; }
.table-scroll { overflow: auto; max-width: 100%; }
.attendance-table { width: 100%; min-width: 960px; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.attendance-table th, .attendance-table td { min-width: 42px; height: 48px; padding: 0 9px; border-bottom: 1px solid #1d2d3a; text-align: center; }
.attendance-table thead th { position: sticky; top: 0; z-index: 1; background: #152431; color: #9eb0bd; font-size: .78rem; }
.attendance-table th:first-child, .attendance-table td:first-child { position: sticky; left: 0; min-width: 100px; text-align: left; background: #111d29; z-index: 2; font-weight: 800; }
.attendance-table thead th:first-child { z-index: 3; background: #152431; }
.attendance-table .total-col { min-width: 78px; color: #f3d36e; font-weight: 800; }
.attendance-table th:nth-child(2), .attendance-table td:nth-child(2) { position: sticky; left: 100px; z-index: 2; background: #142330; box-shadow: 1px 0 #263746; }
.attendance-table thead th:nth-child(2) { z-index: 3; background: #1a2b39; }
.payroll-table { min-width: 980px; }
.payroll-table td { min-width: 150px; }
.payroll-edit { display:flex; align-items:center; justify-content:center; gap:5px; }
.payroll-save-month { display:block; margin:6px auto 0; padding:5px 8px; font-size:.7rem; white-space:nowrap; }
.payroll-edit-month { display:block; margin:7px auto 0; min-width:64px; min-height:34px; padding:7px 13px; border:0; border-radius:8px; color:#fff; font-size:.78rem; font-weight:800; cursor:pointer; box-shadow:0 2px 6px rgba(0,0,0,.22); }
.payroll-edit-action { background:#2576c5; }
.payroll-edit-action:hover { background:#338ddd; }
.payroll-save-action { background:#16845c; }
.payroll-save-action:hover { background:#21a873; }
.payroll-edit-month:disabled { opacity:.6; cursor:wait; }
.permission-group { display:flex; flex-wrap:wrap; align-items:center; gap:8px 12px; padding:9px 12px; border:1px solid #29404f; border-radius:8px; background:#101d28; }
.inline-form { display:flex; flex-wrap:wrap; align-items:center; gap:12px; }
.inline-form > input, .inline-form > select { min-height:44px; padding:0 13px; border:1px solid var(--line); border-radius:10px; outline:none; background:#0d1822; color:var(--ink); }
.inline-form > input:focus, .inline-form > select:focus { border-color:var(--cyan); box-shadow:0 0 0 3px rgba(87,215,220,.12); }
.inline-form > select[multiple] { min-height:92px; padding:8px 10px; }
.permission-group > span { width:100%; color:#a7bcc8; font-size:.78rem; font-weight:800; }
.permission-check { display:flex; align-items:center; gap:5px; color:#e8f1f4; font-size:.8rem; }
.chart-axis-label { fill:#8fa4b2; font-size:10px; }
.dashboard-two-col { display:grid; grid-template-columns:1.15fr .85fr; gap:18px; }
.dashboard-mini-grid { display:grid; grid-template-columns:repeat(2,1fr); gap:12px; }
.dashboard-mini-grid > div { padding:15px; border:1px solid var(--line); border-radius:10px; background:#0d1822; }
.dashboard-mini-grid span, .dashboard-mini-grid strong { display:block; }
.dashboard-mini-grid span { color:#9eb0bd; font-size:.78rem; }
.dashboard-mini-grid strong { margin-top:6px; color:var(--ink); font-size:1.35rem; }
.danger-text { color:#ff8e8e !important; } .warn-text { color:#e4b85c !important; }
@media (max-width: 900px) { .dashboard-two-col { grid-template-columns:1fr; } }
.payroll-input { width: 92px; padding: 7px 6px; border: 1px solid #375062; border-radius: 7px; background:#0d1822; color:#eef6fa; text-align:right; font-variant-numeric:tabular-nums; }
.payroll-save { padding: 6px 8px; font-size:.72rem; }
.payroll-source { display:block; margin-top:4px; color:#8fa4b2; font-size:.7rem; font-weight:500; }
.payroll-pending { color:#e4b85c; font-size:.8rem; }
.attendance-table th.holiday-day { color: #ff8e8e; background: #2b1b25; }
.attendance-table td.holiday-day { background: rgba(255, 84, 105, .045); }
.attendance-table td.holiday-day .month-hour-input { border-color: #63333e; color: #ff9ca8; }
.attendance-table td.holiday-day .month-hour-input.filled { background: rgba(255, 84, 105, .12); }
.month-hour-input { width: 38px; min-height: 34px; padding: 3px 2px; border: 1px solid #263746; border-radius: 7px; outline: none; background: rgba(7,16,24,.34); color: var(--ink); text-align: center; font-weight: 750; font-variant-numeric: tabular-nums; appearance: textfield; }
.month-hour-input::-webkit-inner-spin-button, .month-hour-input::-webkit-outer-spin-button { appearance: none; margin: 0; }
.month-hour-input.filled { background: rgba(87,215,220,.11); color: #86e9ed; }
.month-hour-input.changed { border-color: var(--accent); background: rgba(245,197,66,.14); color: #ffe58e; }
.month-hour-input:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(87,215,220,.14); }
.month-hour-input.selected-for-note { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(245,197,66,.13); }
.month-hour-input:invalid { border-color: var(--danger); background: rgba(255,115,115,.1); }
.empty-table { padding: 42px; color: var(--muted); text-align: center; }
.entry-panel { padding: 20px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 18px; }
.entry-panel h2 { margin: 0 0 6px; font-size: 1.12rem; }
.entry-panel > p { color: var(--muted); margin: 0 0 22px; font-size: .86rem; line-height: 1.6; }
.entry-panel h2, .entry-panel > p, .entry-panel .form-actions, .entry-panel .form-error { grid-column: 1 / -1; }
.entry-panel .field input, .entry-panel .field select, .entry-panel .field textarea { background: #0d1822; color: var(--ink); border-color: var(--line); }
.entry-panel textarea { min-height: 82px; resize: vertical; }
.form-actions { display: flex; gap: 9px; }
.form-actions .secondary-button { flex: 1; }
.form-actions .danger-button { display: none; }
.form-actions.editing .danger-button { display: block; }
.mobile-list { display: none; }
.mobile-month-grid { display: grid; grid-template-columns: repeat(7, minmax(38px, 1fr)); gap: 8px; }
.mobile-day-field { display: grid; gap: 4px; color: var(--muted); font-size: .72rem; text-align: center; }
.mobile-day-field.holiday-day { color: #ff8e8e; }
.mobile-day-field.holiday-day .month-hour-input { border-color: #63333e; color: #ff9ca8; background: rgba(255,84,105,.06); }
.mobile-day-field .month-hour-input { width: 100%; min-width: 0; border-color: #27404f; background: #0a141d; }
.mobile-day-field .month-hour-input.filled { background: rgba(87,215,220,.11); }
.mobile-day-field .month-hour-input.changed { border-color: var(--accent); background: rgba(245,197,66,.14); }
.hidden { display: none !important; }
.battery-content { display: grid; gap: 20px; }
.battery-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 18px; }
.battery-search { display: grid; gap: 8px; width: min(460px, 100%); color: var(--muted); font-size: .82rem; font-weight: 750; }
.battery-search input { min-height: 48px; padding: 0 15px; border: 1px solid var(--line); border-radius: 12px; outline: none; background: var(--panel); color: var(--ink); }
.battery-search input:focus { border-color: var(--cyan); box-shadow: 0 0 0 4px rgba(87,215,220,.12); }
.battery-count { color: var(--muted); font-size: .86rem; }
.battery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 12px; align-items: start; }
.battery-card { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 13px; background: var(--panel); box-shadow: var(--shadow); }
.battery-gallery { background: #09131d; }
.battery-main-zoom { display: block; width: 100%; padding: 0; border: 0; background: #071018; cursor: zoom-in; }
.battery-main-image { display: block; width: 100%; height: 165px; object-fit: contain; background: #071018; }
.battery-thumbs { display: flex; gap: 6px; padding: 7px; overflow-x: auto; border-top: 1px solid var(--line); }
.battery-thumb { flex: 0 0 45px; width: 45px; height: 36px; padding: 0; overflow: hidden; border: 2px solid transparent; border-radius: 7px; background: #071018; }
.battery-thumb.active { border-color: var(--accent); }
.battery-thumb img { width: 100%; height: 100%; object-fit: cover; }
.battery-no-image { display: grid; place-items: center; align-content: center; gap: 9px; height: 165px; color: var(--muted); background: #0a151f; font-size: .78rem; }
.battery-card-body { padding: 13px; }
.battery-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.battery-card-head h2 { margin: 0; font-size: 1.12rem; letter-spacing: -.025em; }
.battery-card-actions { display: flex; align-items: center; gap: 9px; }
.battery-card-actions > span { color: var(--muted); font-size: .77rem; white-space: nowrap; }
.battery-edit-button { min-height: 30px; padding: 0 9px; border-radius: 8px; font-size: .72rem; }
.battery-facts { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
.battery-facts span { padding: 4px 7px; border: 1px solid #304654; border-radius: 999px; color: #b6c9d4; background: #0d1923; font-size: .68rem; }
.battery-details { margin-top: 11px; border-top: 1px solid var(--line); }
.battery-details summary { padding-top: 10px; color: #f2cf61; font-size: .8rem; font-weight: 750; cursor: pointer; }
.battery-details dl { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin: 16px 0 0; }
.battery-details dl > div { min-width: 0; }
.battery-details dt { margin-bottom: 3px; color: var(--muted); font-size: .72rem; font-weight: 700; }
.battery-details dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink); font-size: .88rem; line-height: 1.5; }
.battery-spec-section { margin-top: 18px; padding-top: 15px; border-top: 1px solid var(--line); }
.battery-spec-section h3 { margin: 0 0 8px; color: #f2cf61; font-size: .9rem; }
.battery-spec-section p { margin: 0 0 11px; white-space: pre-wrap; color: var(--ink); font-size: .86rem; line-height: 1.5; }
.battery-section-images { display: grid; grid-template-columns: repeat(auto-fill, minmax(105px, 1fr)); gap: 9px; }
.battery-section-photo { display: block; width: 100%; padding: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: #071018; cursor: zoom-in; }
.battery-section-photo img { display: block; width: 100%; height: 92px; object-fit: cover; }
.battery-section-empty { padding: 12px; border-radius: 9px; color: var(--muted); background: #0a151f; font-size: .8rem; }
.battery-form-panel { scroll-margin-top: 18px; }
.battery-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 16px; padding: 20px; }
.battery-form .field input, .battery-form .field textarea { background: #0d1822; color: var(--ink); border-color: var(--line); }
.battery-form .field textarea { min-height: 88px; resize: vertical; }
.battery-form .battery-wide { grid-column: span 2; }
.battery-form .battery-full { grid-column: 1 / -1; }
.battery-form input[type="file"] { padding-block: 10px; }
.image-drop-zone { display: grid; gap: 7px; padding: 15px; border: 2px dashed #385363; border-radius: 12px; background: #0a151f; transition: .18s; }
.image-drop-zone > strong { color: #dfe9ee; font-size: .88rem; }
.image-drop-zone > span { color: var(--muted); font-size: .76rem; }
.image-drop-zone.dragging { border-color: var(--accent); background: rgba(245,197,66,.1); transform: translateY(-1px); }
.image-preview { display: flex; flex-wrap: wrap; gap: 7px; }
.image-preview span { padding: 6px 9px; border-radius: 8px; color: #a9bbc7; background: #0b151e; font-size: .76rem; }
.existing-image-editor { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.existing-image-group { min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #0b151e; }
.existing-image-group h3 { margin: 0 0 10px; color: #f2cf61; font-size: .9rem; }
.existing-image-group > p { margin: 0; color: var(--muted); font-size: .8rem; }
.existing-image-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.existing-image-item { display: grid; gap: 7px; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: #0a151f; color: var(--muted); font-size: .78rem; cursor: pointer; }
.existing-image-item img { width: 100%; height: 100px; object-fit: cover; border-radius: 7px; }
.existing-image-item span { display: flex; align-items: center; gap: 6px; }
.existing-image-item input { width: 17px !important; min-height: 17px !important; height: 17px; padding: 0 !important; accent-color: var(--danger); }
.battery-form-actions { display: flex; justify-content: flex-end; }
.battery-form-actions .secondary-button { min-width: 180px; }
.image-lightbox { width: min(94vw, 1100px); max-width: none; height: min(90vh, 850px); padding: 44px 16px 16px; border: 1px solid #425765; border-radius: 16px; background: #071018; box-shadow: 0 24px 80px rgba(0,0,0,.65); }
.image-lightbox::backdrop { background: rgba(0,0,0,.82); backdrop-filter: blur(5px); }
.image-lightbox img { width: 100%; height: 100%; object-fit: contain; }
.lightbox-close { position: absolute; top: 7px; right: 10px; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 50%; background: #20303b; color: #fff; font-size: 1.5rem; line-height: 1; }
.inventory-content { display: grid; gap: 20px; }
.inventory-summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.inventory-summary-card { padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
.inventory-summary-card span { display: block; color: var(--muted); font-size: .78rem; font-weight: 750; }
.inventory-summary-card strong { display: block; margin-top: 7px; font-size: 1.75rem; }
.inventory-summary-card.danger { border-color: #673842; background: rgba(255,115,115,.08); }
.inventory-summary-card.danger strong { color: #ff9090; }
.inventory-summary-card.warning { border-color: #695a2c; background: rgba(245,197,66,.07); }
.inventory-summary-card.warning strong { color: #f5d56e; }
.inventory-toolbar { display: grid; grid-template-columns: minmax(240px, 1fr) 180px 190px auto; gap: 12px; align-items: end; }
.inventory-toolbar label { display: grid; gap: 7px; color: var(--muted); font-size: .78rem; font-weight: 750; }
.inventory-toolbar input, .inventory-toolbar select { min-height: 45px; padding: 0 13px; border: 1px solid var(--line); border-radius: 11px; outline: none; background: var(--panel); color: var(--ink); }
.inventory-toolbar input:focus, .inventory-toolbar select:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(87,215,220,.12); }
.inventory-result-count { padding-bottom: 13px; color: var(--muted); font-size: .8rem; white-space: nowrap; }
.inventory-table-scroll, .inventory-history-scroll { overflow: auto; }
.inventory-table, .inventory-history-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.inventory-table { min-width: 980px; }
.inventory-history-table { min-width: 760px; }
.inventory-table th, .inventory-table td, .inventory-history-table th, .inventory-history-table td { padding: 12px 14px; border-bottom: 1px solid #1d2d3a; text-align: left; vertical-align: middle; }
.inventory-table th, .inventory-history-table th { color: #9eb0bd; background: #152431; font-size: .76rem; }
.inventory-table td { font-size: .86rem; }
.inventory-table td > strong, .inventory-table td > small { display: block; }
.inventory-table td > small { margin-top: 4px; color: var(--muted); font-size: .72rem; }
.inventory-name-cell { display: flex; align-items: center; gap: 9px; min-width: 210px; }
.inventory-photo { flex: 0 0 46px; width: 46px; height: 46px; padding: 0; overflow: hidden; border: 1px solid #385363; border-radius: 8px; background: #0a151f; cursor: zoom-in; }
.inventory-photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.inventory-photo-placeholder { display: grid; place-items: center; flex: 0 0 46px; width: 46px; height: 46px; border: 1px dashed #385363; border-radius: 8px; color: #718694; background: #0a151f; font-size: .58rem; text-align: center; }
.number-cell { white-space: nowrap; font-weight: 800; }
.number-cell small, .inventory-card-numbers small { color: var(--muted); font-weight: 600; }
.shortage-number { color: #ff8b8b; }
.inventory-pending { color: var(--muted); font-size: .76rem; font-weight: 650; }
.stock-badge { display: inline-block; flex-shrink: 0; padding: 5px 8px; border-radius: 999px; font-size: .7rem; font-weight: 800; white-space: nowrap; }
.stock-badge.shortage { color: #ffc0c0; background: rgba(255,115,115,.15); }
.stock-badge.critical { color: #ffe493; background: rgba(245,197,66,.14); }
.stock-badge.safe { color: #9ce6bc; background: rgba(83,201,132,.14); }
.stock-badge.pending { color: #b5c4ce; background: #243441; }
.inventory-actions { display: flex; gap: 6px; }
.inventory-actions button { min-height: 32px; padding: 0 10px; border-radius: 8px; font-size: .72rem; white-space: nowrap; }
.inventory-form, .transaction-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 15px; padding: 20px; }
.inventory-form .field input, .inventory-form .field textarea, .transaction-form .field input, .transaction-form .field select { color: var(--ink); border-color: var(--line); background: #0d1822; }
.inventory-form textarea { min-height: 82px; resize: vertical; }
.inventory-name-field { grid-column: span 2; }
.inventory-notes-field { grid-column: span 3; }
.transaction-note-field { grid-column: span 1; }
.inventory-full { grid-column: 1 / -1; }
.inventory-form-actions { display: flex; justify-content: flex-end; }
.inventory-form-actions .secondary-button { min-width: 180px; }
.transaction-help { margin: -4px 0 8px; color: var(--muted); font-size: .78rem; }
.quantity-in { color: #92e1b4; font-weight: 800; }
.quantity-out { color: #ff9c9c; font-weight: 800; }
.inventory-mobile-list { display: none; }
.inventory-mobile-card { padding: 15px; border-bottom: 1px solid var(--line); }
.inventory-card-head { display: flex; justify-content: space-between; gap: 12px; }
.inventory-card-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.inventory-card-title > div:last-child { min-width: 0; }
.inventory-card-title .inventory-photo, .inventory-card-title .inventory-photo-placeholder { flex-basis: 58px; width: 58px; height: 58px; }
.inventory-card-head strong, .inventory-card-head span { display: block; }
.inventory-card-head > div > span { margin-top: 3px; color: var(--muted); font-size: .72rem; }
.inventory-card-spec { margin: 10px 0; color: #b7c7d1; font-size: .8rem; }
.inventory-card-numbers { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-bottom: 12px; }
.inventory-card-numbers > div { padding: 10px; border-radius: 9px; background: #0b161f; }
.inventory-card-numbers span { display: block; margin-bottom: 4px; color: var(--muted); font-size: .68rem; }
.inventory-card-numbers strong { font-size: .9rem; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 20; transform: translateY(18px); opacity: 0; pointer-events: none; padding: 13px 16px; border-radius: 11px; background: #f4f0df; color: #17202a; font-weight: 800; box-shadow: var(--shadow); transition: .2s; }
.toast.show { transform: translateY(0); opacity: 1; }
.loading { min-height: 100vh; display: grid; place-items: center; color: var(--muted); }

@media (max-width: 1040px) {
  .workspace-grid { grid-template-columns: 1fr; }
  .entry-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
  .entry-panel h2, .entry-panel > p, .entry-panel .form-actions, .entry-panel .form-error { grid-column: 1 / -1; }
  .battery-form { grid-template-columns: 1fr 1fr; }
  .inventory-toolbar { grid-template-columns: 1fr 1fr; }
  .inventory-result-count { padding: 0; }
  .inventory-form, .transaction-form { grid-template-columns: 1fr 1fr; }
  .inventory-notes-field, .transaction-note-field { grid-column: span 2; }
}

@media (max-width: 820px) {
  .login-shell { padding: 16px; }
  .auth-card { padding: 26px 22px; }
  .app-shell { grid-template-columns: 1fr; }
  .mobile-menu-toggle { display:flex; position:fixed; top:14px; left:14px; z-index:30; width:44px; height:44px; align-items:center; justify-content:center; border:1px solid var(--line); border-radius:10px; background:#162735; color:var(--ink); font-size:1.35rem; cursor:pointer; }
  .sidebar { position:fixed; z-index:20; inset:0 auto 0 0; width:270px; height:100vh; padding:70px 20px 24px; transform:translateX(-105%); transition:transform .2s ease; border-right:1px solid var(--line); box-shadow:12px 0 30px rgba(0,0,0,.35); }
  .sidebar.mobile-open { transform:translateX(0); }
  .side-brand { padding: 0; }
  .side-brand > span { display: none; }
  .nav-label, .sidebar-footer .user-role, .sidebar-footer .user-name { display: none; }
  .sidebar nav { margin: 20px 0 0; display: flex; flex-direction:column; }
  .nav-item { width: 100%; margin: 3px 0; padding: 0 12px; }
  .nav-item.disabled { display: none; }
  .sidebar-footer { margin: 0 0 0 auto; padding: 0; border: 0; }
  .logout-link { margin: 0; }
  .topbar { align-items: flex-start; }
  .topbar-actions { flex-direction: column; align-items: stretch; }
  .topbar-actions .secondary-button { min-height: 44px; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .summary-card:first-child { grid-column: 1 / -1; }
  .year-dashboard-head { display: block; }
  .year-metrics { margin-top: 18px; }
  .inventory-summary-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 620px) {
  .topbar { padding: 20px; flex-direction: column; }
  .topbar-actions { width: 100%; flex-direction: row; }
  .month-control { flex: 1; min-width: 0; }
  .top-logout-button { padding-inline: 13px; }
  .content { padding: 16px; }
  .summary-grid { gap: 10px; }
  .summary-card { padding: 16px; }
  .year-dashboard { padding: 18px 16px; }
  .year-metrics { grid-template-columns: 1fr 1fr; }
  .growth-metric { grid-column: 1 / -1; }
  .table-scroll { display: none; }
  .mobile-list { display: block; padding: 12px; }
  .person-card { margin-bottom: 10px; padding: 15px; border: 1px solid var(--line); border-radius: 13px; background: #0e1923; }
  .person-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; margin-bottom: 12px; }
  .person-name { font-weight: 850; }
  .person-total { color: var(--accent); font-size: .88rem; }
  .entry-panel { display: block; }
  .battery-toolbar { display: block; }
  .battery-count { margin-top: 10px; }
  .battery-form { display: block; }
  .battery-main-image, .battery-no-image { height: 180px; }
  .battery-details dl { grid-template-columns: 1fr; }
  .existing-image-editor { grid-template-columns: 1fr; }
  .inventory-toolbar { display: grid; grid-template-columns: 1fr; }
  .inventory-table-scroll { display: none; }
  .inventory-mobile-list { display: block; }
  .inventory-form, .transaction-form { display: block; }
  .inventory-form-actions { margin-top: 8px; }
}

@media (max-width: 420px) {
  .mobile-month-grid { grid-template-columns: repeat(5, minmax(38px, 1fr)); }
  .save-month-button { padding-inline: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
