:root {
  --navy-950: #101a3b;
  --navy-900: #172554;
  --navy-800: #1e3a6d;
  --navy-100: #e8edf6;
  --red-600: #c92332;
  --red-100: #fde8ea;
  --slate-950: #172033;
  --slate-700: #465269;
  --slate-500: #778197;
  --slate-300: #d5dbe6;
  --slate-100: #f2f5f9;
  --white: #fff;
  --green: #16855b;
  --shadow: 0 18px 48px rgba(16, 26, 59, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--slate-950);
  background: var(--slate-100);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(480px, 1.1fr);
  background: var(--white);
}

.login-panel { display: grid; place-items: center; padding: 48px; }
.login-card { width: min(420px, 100%); }
.login-card img { width: 220px; height: auto; margin-bottom: 40px; }
.eyebrow { color: var(--red-600); font-size: 12px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
h1 { margin: 10px 0 8px; font-size: clamp(32px, 5vw, 46px); letter-spacing: -.04em; }
.muted { color: var(--slate-500); line-height: 1.55; }
.form { display: grid; gap: 18px; margin-top: 34px; }
.field { display: grid; gap: 7px; }
.field label { color: var(--slate-700); font-size: 13px; font-weight: 700; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--slate-300); border-radius: 10px; padding: 13px 14px;
  color: var(--slate-950); background: var(--white); outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--navy-800); box-shadow: 0 0 0 3px rgba(30,58,109,.12); }
.field textarea { resize: vertical; min-height: 86px; }
.primary {
  border: 0; border-radius: 10px; padding: 14px 18px; background: var(--navy-900); color: white;
  font-weight: 800; transition: .2s ease;
}
.primary:hover { background: var(--navy-800); transform: translateY(-1px); }
.primary:disabled { opacity: .55; transform: none; cursor: wait; }
.login-visual {
  position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end;
  padding: 64px; color: white; background:
    radial-gradient(circle at 85% 14%, rgba(201,35,50,.85), transparent 28%),
    linear-gradient(145deg, var(--navy-950), var(--navy-800));
}
.login-visual::before, .login-visual::after {
  content: ""; position: absolute; border: 1px solid rgba(255,255,255,.13); border-radius: 50%;
}
.login-visual::before { width: 520px; height: 520px; top: -180px; right: -160px; }
.login-visual::after { width: 760px; height: 760px; top: -300px; right: -270px; }
.visual-copy { position: relative; z-index: 1; max-width: 620px; }
.visual-copy h2 { font-size: clamp(36px, 5vw, 64px); line-height: 1.04; letter-spacing: -.04em; margin: 16px 0; }
.visual-copy p { color: #dbe5f6; font-size: 18px; line-height: 1.6; }
.steps { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 30px; }
.step { border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.08); padding: 9px 12px; border-radius: 999px; font-size: 12px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px 1fr; }
.sidebar { background: var(--navy-950); color: white; padding: 28px 18px; display: flex; flex-direction: column; }
.brand { background: white; border-radius: 10px; padding: 10px 14px; margin: 0 8px 32px; }
.brand img { display: block; width: 150px; height: auto; }
.nav { display: grid; gap: 6px; }
.nav button {
  border: 0; border-radius: 9px; padding: 12px 14px; text-align: left; color: #cbd5e8; background: transparent;
  font-weight: 650;
}
.nav button:hover, .nav button.active { background: rgba(255,255,255,.1); color: white; }
.sidebar-footer { margin-top: auto; padding: 18px 10px 0; border-top: 1px solid rgba(255,255,255,.12); }
.user-name { font-weight: 800; }
.user-role { color: #9daccc; font-size: 12px; margin: 4px 0 14px; text-transform: uppercase; }
.logout { border: 0; background: transparent; color: #f7a4ad; padding: 0; font-weight: 700; }
.main { min-width: 0; }
.topbar { height: 76px; display: flex; align-items: center; justify-content: space-between; padding: 0 34px; background: white; border-bottom: 1px solid #e4e8ef; }
.topbar strong { color: var(--navy-900); }
.environment { color: var(--green); background: #e5f6ef; border-radius: 999px; padding: 7px 11px; font-size: 12px; font-weight: 800; }
.content { padding: 34px; max-width: 1440px; margin: 0 auto; }
.page-title { display: flex; justify-content: space-between; gap: 20px; align-items: end; margin-bottom: 26px; }
.page-title h1 { font-size: 31px; margin: 0; }
.page-title p { margin: 6px 0 0; }
.cards { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 18px; }
.card, .panel { background: white; border: 1px solid #e3e8f0; border-radius: 14px; box-shadow: 0 7px 24px rgba(16,26,59,.04); }
.card { padding: 22px; }
.card-label { color: var(--slate-500); font-size: 13px; font-weight: 700; }
.card-value { color: var(--navy-950); font-size: 34px; font-weight: 850; margin: 7px 0 2px; }
.card-value.small { font-size: 19px; line-height: 1.25; }
.card-note { font-size: 12px; color: var(--green); }
.compact-cards { margin-top: 18px; }
.compact-cards .card { padding: 18px; }
.panel { margin-top: 22px; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px; border-bottom: 1px solid #e8ebf1; }
.panel-head h2 { font-size: 18px; margin: 0; }
.badge { display: inline-flex; align-items: center; padding: 5px 9px; border-radius: 999px; background: var(--navy-100); color: var(--navy-800); font-size: 11px; font-weight: 800; }
.badge.off { color: #9b2630; background: var(--red-100); }
.badge.success { color: var(--green); background: #e5f6ef; }
.badge.warning { color: #8a5b00; background: #fff4d6; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { padding: 14px 22px; text-align: left; border-bottom: 1px solid #edf0f5; }
th { color: var(--slate-500); background: #fafbfd; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
td { font-size: 13px; }
.empty { padding: 48px 24px; text-align: center; color: var(--slate-500); }
.module-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 18px; }
.module { padding: 24px; min-height: 205px; text-align: left; font: inherit; color: inherit; transition: .2s ease; }
.module.available:hover { transform: translateY(-3px); border-color: #bdc9dc; box-shadow: 0 16px 34px rgba(16,26,59,.10); }
.module.planned { cursor: default; opacity: .68; }
.module-top { display: flex; align-items: center; justify-content: space-between; }
.module-number { color: var(--red-600); font-weight: 850; }
.module-status { color: var(--green); background: #e5f6ef; border-radius: 999px; padding: 5px 9px; font-size: 10px; font-weight: 850; text-transform: uppercase; letter-spacing: .04em; }
.module.planned .module-status { color: var(--slate-700); background: var(--slate-100); }
.module h3 { margin: 22px 0 8px; color: var(--navy-900); }
.module p { margin-bottom: 22px; }
.module-action { color: var(--navy-800); font-size: 12px; font-weight: 850; }
.module.planned .module-action { color: var(--slate-500); }
.upload-panel { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 24px; background: linear-gradient(135deg, var(--navy-950), var(--navy-800)); color: white; border-radius: 14px; box-shadow: var(--shadow); }
.upload-panel h2 { margin: 0 0 6px; }
.upload-panel p { margin: 0; color: #cfdaeb; }
.upload-panel form { display: flex; align-items: center; gap: 10px; }
.file-picker { display: inline-flex; align-items: center; padding: 13px 16px; color: white; border: 1px solid rgba(255,255,255,.32); border-radius: 10px; font-size: 13px; font-weight: 800; cursor: pointer; }
.file-picker input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload-panel .primary { background: var(--red-600); white-space: nowrap; }
.import-button { display: inline-flex; align-items: center; justify-content: center; min-width: 160px; cursor: pointer; }
.import-button input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.import-button.busy { opacity: .65; cursor: wait; }
.import-progress { min-height: 18px; margin-top: 8px; color: #fff; font-size: 12px; font-weight: 750; }
.import-result { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-top: 16px; padding: 16px 18px; border-radius: 12px; border: 1px solid #a9dfc8; background: #e9f8f1; color: #116944; }
.import-result.has-errors { color: #85510b; background: #fff5dc; border-color: #efd28b; }
.import-result div { display: grid; gap: 4px; }
.import-result span { font-size: 12px; }
.import-result details { max-width: 55%; font-size: 12px; }
.import-result summary { cursor: pointer; font-weight: 800; }
.import-result ul { max-height: 140px; overflow: auto; margin: 10px 0 0; padding-left: 20px; }
.subtle { margin-top: 4px; max-width: 360px; color: var(--slate-500); font-size: 11px; }
.form-panel { overflow: visible; }
.inline-form { display: grid; grid-template-columns: 1fr 1fr 1.4fr auto; gap: 14px; align-items: end; padding: 20px 22px; }
.inline-form.transfer-form { grid-template-columns: minmax(280px, 2fr) 1fr .7fr auto; }
.inline-form .primary { height: 47px; }
.grid-form { grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: end; margin: 0; padding: 20px 22px; }
.grid-form .span-2 { grid-column: span 2; }
.grid-form .primary { min-height: 47px; }
.certificate-form { grid-template-columns: 2fr 1fr auto; align-items: end; margin: 0; padding: 0 22px 22px; }
.certificate-form .primary { min-height: 47px; }
.field select[multiple] { min-height: 94px; padding: 8px; }
.field.wide { min-width: 0; }
.form-hint { margin: -6px 22px 20px; color: var(--slate-500); font-size: 12px; }
.request-form { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; align-items: end; padding: 20px 22px; }
.request-form .span-2 { grid-column: span 2; }
.request-form .span-3 { grid-column: span 3; }
.request-form .primary { height: 47px; }
.refusal-form { grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: end; margin: 0; padding: 20px 22px; }
.refusal-form .span-2 { grid-column: span 2; }
.refusal-form .primary { min-height: 47px; }
.trace-list { display: grid; gap: 8px; min-width: 250px; }
.trace-item { display: grid; gap: 2px; padding-left: 10px; border-left: 3px solid var(--navy-100); }
.trace-item strong { color: var(--navy-900); }
.trace-item span, .trace-item small { color: var(--slate-500); font-size: 11px; }
.compact-button { padding: 9px 12px; white-space: nowrap; }
.selected-row td { background: #f3f7ff; }
.refusal-dialog { width: min(620px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: 16px; box-shadow: 0 30px 90px rgba(16,26,59,.3); }
.refusal-dialog::backdrop { background: rgba(16,26,59,.62); backdrop-filter: blur(3px); }
.dialog-card { display: grid; gap: 18px; padding: 24px; }
.dialog-head { display: flex; align-items: start; justify-content: space-between; gap: 20px; }
.dialog-head h2 { margin: 5px 0 0; }
.dialog-close { width: 34px; height: 34px; color: var(--slate-700); background: var(--slate-100); border: 0; border-radius: 50%; font-size: 22px; }
.receipt-summary { display: grid; gap: 4px; padding: 14px 16px; color: var(--slate-700); background: var(--slate-100); border-radius: 10px; font-size: 13px; }
.receipt-summary strong { color: var(--navy-900); font-size: 16px; }
.confirmation-check { display: flex; align-items: flex-start; gap: 10px; padding: 14px; color: var(--navy-900); background: #eef7f3; border: 1px solid #b9dfcf; border-radius: 10px; font-size: 13px; font-weight: 750; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }
.stock-search-field { position: relative; }
.stock-results { position: absolute; top: calc(100% - 2px); left: 0; right: 0; z-index: 12; max-height: 330px; overflow-y: auto; background: white; border: 1px solid var(--slate-300); border-radius: 10px; box-shadow: var(--shadow); }
.stock-results:empty { display: none; }
.stock-result { display: grid; gap: 4px; width: 100%; padding: 11px 13px; text-align: left; color: var(--slate-700); background: white; border: 0; border-bottom: 1px solid #edf0f5; }
.stock-result:hover, .stock-result:focus { background: var(--navy-100); outline: none; }
.stock-result span:first-child { color: var(--navy-900); font-size: 12px; }
.stock-result span:last-child { font-size: 11px; }
.stock-search-hint { padding: 14px; color: var(--slate-500); font-size: 12px; }
.selected-stock { display: grid; gap: 3px; min-height: 42px; margin-top: 7px; padding: 9px 11px; color: var(--slate-500); background: var(--slate-100); border-radius: 8px; font-size: 11px; }
.selected-stock strong { color: var(--navy-900); }
.field input[readonly] { color: var(--slate-700); background: var(--slate-100); cursor: default; }
.panel-caption { display: block; margin-top: 4px; color: var(--slate-500); font-size: 11px; }
.send-selected { align-self: center; min-width: 190px; }
.history-panel { margin-top: 30px; }
input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--navy-900); cursor: pointer; }
.quantity-input { text-align: right; font-variant-numeric: tabular-nums; font-weight: 750; }
.table-action { border: 1px solid var(--slate-300); border-radius: 8px; padding: 7px 10px; color: var(--navy-800); background: white; font-size: 11px; font-weight: 800; white-space: nowrap; }
.table-action:hover { border-color: var(--navy-800); }
.table-action.danger { color: var(--red-600); }
.spreadsheet-import-button { display: inline-flex; align-items: center; cursor: pointer; }
.spreadsheet-import-button input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.spreadsheet-import-button.busy { opacity: .6; cursor: wait; pointer-events: none; }
.notice { display: flex; gap: 12px; align-items: center; padding: 15px 18px; color: #6c4c08; background: #fff5d9; border: 1px solid #f0d995; border-radius: 12px; font-size: 13px; }
.notice span { color: #806a3b; }
.production-warning { margin-top: 18px; color: #8f1f2a; background: var(--red-100); border-color: #efb3ba; }
.production-warning span { color: #7a3038; }
.key-text { display: inline-block; max-width: 220px; overflow: hidden; text-overflow: ellipsis; font-family: ui-monospace, monospace; font-size: 11px; }
.toast { position: fixed; right: 22px; bottom: 22px; max-width: 380px; padding: 13px 16px; color: white; background: var(--navy-950); border-radius: 10px; box-shadow: var(--shadow); opacity: 0; transform: translateY(15px); pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #9f2330; }

@media (max-width: 960px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-visual { display: none; }
  .app-shell { grid-template-columns: 84px 1fr; }
  .sidebar { padding-inline: 10px; }
  .brand { padding: 8px; margin-inline: 0; }
  .brand img { width: 48px; object-fit: cover; object-position: left; }
  .nav button { font-size: 0; text-align: center; }
  .nav button::first-letter { font-size: 18px; }
  .sidebar-footer { display: none; }
  .cards { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .module-grid { grid-template-columns: 1fr 1fr; }
  .inline-form, .inline-form.transfer-form { grid-template-columns: 1fr 1fr; }
  .grid-form { grid-template-columns: 1fr 1fr; }
  .certificate-form { grid-template-columns: 1fr 1fr; }
  .request-form { grid-template-columns: 1fr 1fr; }
  .refusal-form { grid-template-columns: 1fr 1fr; }
  .request-form .span-3 { grid-column: span 1; }
}

@media (max-width: 640px) {
  .login-panel { padding: 28px 22px; }
  .app-shell { display: block; }
  .sidebar { position: sticky; top: 0; z-index: 5; flex-direction: row; padding: 9px 12px; overflow-x: auto; }
  .brand { display: none; }
  .nav { display: flex; }
  .nav button { font-size: 12px; white-space: nowrap; }
  .nav button::first-letter { font-size: inherit; }
  .topbar { height: 60px; padding: 0 18px; }
  .content { padding: 22px 16px; }
  .cards, .module-grid { grid-template-columns: 1fr; }
  .page-title { align-items: start; flex-direction: column; }
  .upload-panel, .upload-panel form { align-items: stretch; flex-direction: column; }
  .import-result { flex-direction: column; }
  .import-result details { max-width: 100%; }
  .inline-form, .inline-form.transfer-form { grid-template-columns: 1fr; }
  .grid-form, .certificate-form { grid-template-columns: 1fr; }
  .grid-form .span-2 { grid-column: span 1; }
  .request-form { grid-template-columns: 1fr; }
  .request-form .span-2, .request-form .span-3 { grid-column: span 1; }
  .refusal-form { grid-template-columns: 1fr; }
  .refusal-form .span-2 { grid-column: span 1; }
}
