:root {
  --ink: #1f2422;
  --ink-2: #303633;
  --muted: #727a76;
  --line: #dfe4e1;
  --paper: #f3f5f2;
  --white: #fff;
  --mint: #8fd8cb;
  --mint-light: #dff8f3;
  --mint-dark: #287f70;
  --amber: #efb64d;
  --red: #d85d57;
  --blue: #5d7bd8;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; background: var(--paper); color: var(--ink); font-family: -apple-system, BlinkMacSystemFont, "Noto Sans JP", "Yu Gothic", "Yu Gothic UI", Meiryo, sans-serif; font-feature-settings: "palt"; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.app-shell { display: none; }
body.authenticated .app-shell { display: grid; }

.login-screen { min-height: 100vh; display: grid; grid-template-columns: 1.2fr .8fr; background: var(--ink); color: white; }
body.authenticated .login-screen { display: none; }
.login-brand { padding: 9vw; display: flex; flex-direction: column; justify-content: center; background: radial-gradient(circle at 75% 25%, rgba(143,216,203,.18), rgba(31,36,34,0) 48%); }
.brand-mark.large { width: 70px; height: 70px; font-size: 40px; margin-bottom: 30px; }
.login-brand h1 { font-size: clamp(45px,6vw,84px); line-height: .98; letter-spacing: -.07em; margin: 18px 0 25px; max-width: 720px; }
.login-brand > p:last-child { color: #bdc5c1; font-size: 18px; max-width: 620px; line-height: 1.7; }
.login-card { align-self: center; justify-self: center; width: min(410px,85%); padding: 34px; background: white; color: var(--ink); border-radius: 12px; display: grid; gap: 17px; box-shadow: 0 30px 90px rgba(0,0,0,.35); }
.login-card h2 { margin: 0 0 5px; font-size: 28px; }
.login-card label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 800; }
.login-card input { padding: 12px; border: 1px solid var(--line); border-radius: 7px; outline: none; }
.login-card small { color: var(--muted); line-height: 1.5; }
.form-error { color: var(--red); font-size: 12px; min-height: 16px; margin: 0; }

.app-shell { min-height: 100vh; grid-template-columns: 230px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--ink); color: white; padding: 24px 16px; display: flex; flex-direction: column; }
.brand { display: flex; gap: 12px; align-items: center; padding: 4px 8px 28px; border-bottom: 1px solid rgba(255,255,255,.12); }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; background: var(--mint); color: var(--ink); font-weight: 950; font-size: 24px; clip-path: polygon(12% 0,100% 0,88% 100%,0 100%); }
.brand strong { display: block; letter-spacing: .08em; }
.brand span, .sidebar-footer span { display: block; color: #aeb7b2; font: 11px/1.4 Consolas, monospace; letter-spacing: .08em; }
.nav { display: grid; gap: 5px; padding-top: 24px; }
.nav-item { border: 0; background: transparent; color: #bdc5c1; text-align: left; padding: 13px 14px; border-radius: 8px; display: flex; gap: 12px; align-items: center; font-weight: 700; }
.nav-item span { width: 21px; color: var(--mint); font: 18px/1 Consolas, monospace; text-align: center; }
.nav-item:hover, .nav-item.active { background: #38413d; color: white; }
.nav-item.active { box-shadow: inset 3px 0 var(--mint); }
.sidebar-footer { margin-top: auto; padding: 15px 10px; border: 1px solid rgba(255,255,255,.12); border-radius: 8px; display: flex; align-items: center; gap: 10px; }
.sidebar-footer strong { font-size: 12px; }
.sync-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 0 5px rgba(143,216,203,.12); }

.main { min-width: 0; padding: 0 34px 48px; }
.topbar { height: 106px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); margin-bottom: 28px; }
.topbar h1 { margin: 2px 0 0; font-size: 28px; letter-spacing: -.04em; }
.eyebrow { margin: 0; color: var(--muted); font: 700 11px/1.3 Consolas, monospace; letter-spacing: .14em; }
.eyebrow.mint { color: var(--mint); }
.top-actions { display: flex; align-items: center; gap: 13px; }
.global-search { width: 280px; height: 42px; display: flex; align-items: center; gap: 9px; padding: 0 13px; background: white; border: 1px solid var(--line); border-radius: 8px; }
.global-search input { width: 100%; border: 0; outline: 0; background: transparent; }
.icon-button { position: relative; width: 42px; height: 42px; border: 1px solid var(--line); background: white; border-radius: 8px; color: var(--muted); }
.notification-dot { position: absolute; right: 8px; top: 8px; width: 7px; height: 7px; border-radius: 50%; background: var(--red); }
.user { display: flex; gap: 10px; align-items: center; padding: 0 8px 0 5px; border: 0; background: transparent; text-align: left; }
.user > span { width: 39px; height: 39px; display: grid; place-items: center; border-radius: 50%; background: var(--ink); color: var(--mint); font-weight: 900; }
.user strong, .user small { display: block; }
.user strong { font-size: 13px; }
.user small { color: var(--muted); margin-top: 2px; }

.view { display: none; }
.active-view { display: block; }
.hero { min-height: 224px; background: var(--ink-2); color: white; padding: 37px 42px; border-radius: 12px; display: flex; justify-content: space-between; align-items: center; overflow: hidden; position: relative; }
.hero:after { content: ""; position: absolute; width: 430px; height: 430px; right: -100px; top: -230px; border: 70px solid rgba(143,216,203,.09); border-radius: 50%; }
.hero h2 { font-size: clamp(30px,3vw,47px); line-height: 1.12; letter-spacing: -.055em; margin: 12px 0 15px; }
.hero p:not(.eyebrow) { color: #cbd2ce; margin: 0; }
.hero-badge { position: relative; z-index: 1; width: 140px; height: 140px; border-radius: 50%; background: var(--mint); color: var(--ink); display: grid; align-content: center; text-align: center; box-shadow: 0 0 0 16px rgba(143,216,203,.08); }
.hero-badge strong { font: 900 48px/1 Consolas, monospace; }
.hero-badge span { margin-top: 7px; font-weight: 800; font-size: 13px; }

.stats-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; margin: 18px 0; }
.brand-overview { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; margin-bottom: 18px; }
.brand-card { border: 1px solid var(--line); background: white; border-radius: 10px; padding: 17px; text-align: left; display: grid; gap: 5px; }
.brand-card span { color: var(--muted); font: 700 10px/1 Consolas, monospace; letter-spacing: .12em; }
.brand-card strong { font-size: 21px; letter-spacing: .04em; }
.brand-card small { color: var(--muted); }
.brand-card.premium { color: white; background: linear-gradient(135deg,#202522,#3e4944); border-color: #202522; }
.brand-card.premium span, .brand-card.premium small { color: var(--mint); }
.stat-card { background: white; border: 1px solid var(--line); border-radius: 10px; padding: 21px; display: flex; justify-content: space-between; min-height: 118px; }
.stat-card strong { display: block; font: 900 28px/1.1 Consolas, monospace; margin: 12px 0 5px; }
.stat-card small { color: var(--muted); }
.stat-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 8px; background: var(--mint-light); color: var(--mint-dark); font-weight: 900; }
.dashboard-grid { display: grid; grid-template-columns: 1.4fr .9fr; gap: 18px; margin-bottom: 18px; }
.panel { background: white; border: 1px solid var(--line); border-radius: 10px; padding: 22px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.panel h3 { margin: 5px 0 0; font-size: 18px; }
.text-button { border: 0; background: transparent; color: var(--mint-dark); font-weight: 800; }
.count-badge { padding: 5px 9px; background: #fdebea; color: var(--red); border-radius: 99px; font-weight: 900; }
.health-list { display: grid; gap: 17px; }
.health-row { display: grid; grid-template-columns: 110px 1fr 42px; gap: 12px; align-items: center; font-size: 13px; font-weight: 700; }
.bar { height: 9px; border-radius: 20px; background: #e8ece9; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; background: var(--mint); }
.alert-list { display: grid; gap: 10px; }
.alert-item { display: grid; grid-template-columns: 34px 1fr; gap: 11px; padding: 11px; background: #fafbfa; border: 1px solid var(--line); border-radius: 8px; }
.alert-item > span { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: #fff0d5; color: #a66c06; font-weight: 900; }
.alert-item strong { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.alert-item small { color: var(--muted); }

.movement-table { display: grid; }
.movement-row { display: grid; grid-template-columns: 105px 1.4fr .8fr .7fr .7fr; gap: 12px; padding: 13px 5px; border-top: 1px solid var(--line); align-items: center; font-size: 13px; }
.movement-row:first-child { border-top: 0; }
.movement-type { font-weight: 800; }
.movement-type.in { color: var(--mint-dark); }
.movement-type.out { color: var(--red); }
.movement-type.transfer { color: var(--blue); }

.primary-button, .secondary-button { border-radius: 7px; padding: 10px 15px; font-weight: 800; }
.primary-button { border: 1px solid var(--ink); background: var(--ink); color: white; }
.primary-button:hover { background: #3b4440; }
.secondary-button { border: 1px solid var(--line); background: white; color: var(--ink); }

.toolbar { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 17px; }
.filter-group, .toolbar-actions { display: flex; gap: 10px; }
select { min-width: 160px; padding: 10px 12px; border: 1px solid var(--line); background: white; border-radius: 7px; outline: none; }
.product-summary { display: flex; gap: 10px; margin-bottom: 14px; }
.summary-chip { border: 1px solid var(--line); border-radius: 99px; padding: 8px 12px; background: white; font-size: 12px; color: var(--muted); }
.summary-chip strong { color: var(--ink); }
.product-table-wrap { background: white; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.product-table { width: 100%; border-collapse: collapse; }
.product-table th { color: var(--muted); background: #f8faf8; text-align: left; font-size: 11px; letter-spacing: .07em; padding: 13px; white-space: nowrap; }
.product-table td { padding: 12px 13px; border-top: 1px solid var(--line); font-size: 13px; vertical-align: middle; }
.product-info { min-width: 310px; display: grid; grid-template-columns: 54px 1fr; gap: 12px; align-items: center; }
.product-info img { width: 54px; height: 54px; object-fit: contain; background: white; border: 1px solid var(--line); border-radius: 6px; }
.product-info strong { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.35; }
.product-info small { display: block; color: var(--muted); margin-top: 4px; font-family: Consolas, monospace; }
.brand-inline { display: inline-block; margin-bottom: 5px; padding: 3px 6px; border-radius: 4px; background: #edf1ef; color: var(--muted); font: 800 9px/1 Consolas, monospace; letter-spacing: .08em; }
.brand-inline.premium { background: var(--ink); color: var(--mint); }
.stock-number { font: 800 14px/1 Consolas, monospace; }
.status { display: inline-block; padding: 5px 8px; border-radius: 99px; font-size: 11px; font-weight: 900; white-space: nowrap; }
.status.normal { background: var(--mint-light); color: var(--mint-dark); }
.status.low, .status.reserved { background: #fff1d8; color: #98630b; }
.status.zero, .status.soldout { background: #fde9e8; color: #ad3f39; }
.row-actions { display: flex; gap: 7px; min-width: 150px; }
.row-action { border: 1px solid var(--line); background: #f7f9f7; padding: 7px 9px; border-radius: 6px; font-size: 11px; font-weight: 900; white-space: nowrap; }
.row-action:hover { border-color: var(--mint-dark); color: var(--mint-dark); }
.plan-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; }
.plan-card { background: white; border: 1px solid var(--line); border-radius: 10px; padding: 18px; display: grid; gap: 13px; }
.plan-card.done { opacity: .65; }
.plan-card h3 { margin: 0; font-size: 16px; }
.plan-meta { display: flex; flex-wrap: wrap; gap: 7px; color: var(--muted); font-size: 12px; }
.plan-notes { color: var(--muted); font-size: 13px; line-height: 1.6; min-height: 42px; }
.priority-high { color: var(--red); }
.priority-medium { color: #98630b; }
.priority-low { color: var(--mint-dark); }

.simple-entry-hero { background: var(--ink-2); color: white; border-radius: 12px; padding: 30px 34px; display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.simple-entry-hero h2 { font-size: 34px; margin: 8px 0; }
.simple-entry-hero p:last-child { color: #cbd2ce; }
.approval-count { width: 100px; height: 100px; border-radius: 50%; background: var(--mint); color: var(--ink); display: grid; place-content: center; text-align: center; font: 900 32px/1 Consolas, monospace; }
.approval-count small { display: block; margin-top: 6px; font: 800 11px/1 sans-serif; }
.simple-entry-card { background: white; border: 1px solid var(--line); border-radius: 12px; padding: 24px; display: grid; grid-template-columns: repeat(2,1fr); gap: 18px; margin-bottom: 18px; }
.simple-entry-card label { display: grid; gap: 8px; }
.simple-entry-card label > span { font-size: 13px; font-weight: 900; }
.simple-entry-card input, .simple-entry-card select { width: 100%; min-height: 52px; padding: 12px; border: 2px solid var(--line); border-radius: 8px; background: white; }
.simple-entry-card .wide, .entry-submit { grid-column: 1 / -1; }
.quantity-field input { font: 900 30px/1 Consolas, monospace; text-align: center; }
.entry-submit { min-height: 56px; font-size: 16px; }
.request-list { display: grid; gap: 10px; }
.request-card { display: grid; grid-template-columns: 90px minmax(260px,1.5fr) minmax(120px,.7fr) 70px 90px auto; gap: 12px; align-items: center; background: white; border: 1px solid var(--line); border-radius: 9px; padding: 14px; }
.request-card strong, .request-card small { display: block; }
.request-card small { color: var(--muted); margin-top: 4px; }
.brand-badge { padding: 7px; border-radius: 5px; background: #edf1ef; text-align: center; font: 900 11px/1 Consolas, monospace; }
.brand-badge.premium { background: var(--ink); color: var(--mint); }
.request-quantity { font: 900 24px/1 Consolas, monospace; text-align: center; }
.request-actions { display: flex; gap: 7px; }
.approval-note { padding: 14px 17px; background: #fff5df; color: #805712; border: 1px solid #f0d99f; border-radius: 8px; margin-bottom: 14px; font-weight: 700; }
.processed-head { margin-top: 28px; }

.document-layout { display: grid; grid-template-columns: 1fr 330px; gap: 18px; }
.document-list { display: grid; gap: 10px; }
.document-card { background: white; border: 1px solid var(--line); border-radius: 9px; padding: 17px; display: grid; grid-template-columns: 110px 1fr 120px 120px; gap: 14px; align-items: center; }
.document-card strong { display: block; }
.document-card small { color: var(--muted); }
.workflow { background: var(--ink-2); color: white; border-radius: 10px; padding: 23px; }
.workflow h3 { margin-top: 5px; }
.workflow-step { display: flex; gap: 12px; margin-top: 18px; }
.workflow-step b { flex: 0 0 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: var(--mint); color: var(--ink); }
.workflow-step span { color: #cbd2ce; font-size: 13px; line-height: 1.5; }
.empty-state { padding: 55px; background: white; border: 1px solid var(--line); border-radius: 10px; text-align: center; }
.audit-detail { display: grid; gap: 3px; }
.audit-change { font-family: Consolas, monospace; font-size: 12px; }
.role-chip { display: inline-block; border-radius: 99px; padding: 5px 9px; background: var(--mint-light); color: var(--mint-dark); font-size: 11px; font-weight: 900; }
.live-pill { display: inline-flex; align-items: center; gap: 7px; color: var(--mint-dark); font-size: 12px; font-weight: 800; }
.live-pill:before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 0 4px var(--mint-light); }

dialog { width: min(600px, calc(100vw - 30px)); border: 0; border-radius: 12px; padding: 0; box-shadow: 0 24px 80px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(24,29,27,.55); }
#modal-form { padding: 24px; }
.modal-head { display: flex; justify-content: space-between; align-items: start; border-bottom: 1px solid var(--line); padding-bottom: 18px; }
.modal-head h3 { margin: 5px 0 0; font-size: 22px; }
.close-button { border: 0; background: #eef1ef; width: 34px; height: 34px; border-radius: 50%; font-size: 22px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; padding: 20px 0; }
.field { display: grid; gap: 7px; }
.field.full { grid-column: 1 / -1; }
.field label { color: var(--muted); font-size: 12px; font-weight: 800; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid var(--line); border-radius: 7px; padding: 11px; outline: none; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; border-top: 1px solid var(--line); padding-top: 18px; }

@media (max-width: 1050px) {
  .app-shell { grid-template-columns: 76px 1fr; }
  .sidebar { padding-inline: 10px; }
  .brand > div:last-child, .nav-item:not(.active) { font-size: 0; }
  .nav-item { justify-content: center; }
  .nav-item span { font-size: 19px; }
  .sidebar-footer { display: none; }
  .stats-grid { grid-template-columns: repeat(2,1fr); }
  .brand-overview { grid-template-columns: repeat(2,1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .login-screen { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  body.authenticated .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; flex-direction: row; align-items: center; overflow-x: auto; }
  .brand { border: 0; padding: 0 16px 0 0; }
  .nav { display: flex; padding: 0; }
  .nav-item { min-width: 52px; }
  .main { padding: 0 16px 35px; }
  .topbar { height: auto; padding: 20px 0; align-items: flex-start; }
  .top-actions .user, .icon-button { display: none; }
  .global-search { width: 210px; }
  .stats-grid { grid-template-columns: 1fr; }
  .hero-badge { display: none; }
  .product-table-wrap { overflow-x: auto; }
  .document-layout { grid-template-columns: 1fr; }
  .plan-grid { grid-template-columns: 1fr; }
  .simple-entry-card { grid-template-columns: 1fr; }
  .simple-entry-card .wide, .entry-submit { grid-column: auto; }
  .request-card { grid-template-columns: 70px 1fr 60px; }
  .request-card > :nth-child(3), .request-card > :nth-child(5) { display: none; }
  .request-actions { grid-column: 1 / -1; }
}
