/* ==========================================================================
   KALKULATOR AKURASI INVENTORI GUDANG (IRA) & CYCLE COUNTING — dwik.web.id
   Acuan: APICS / ASCM, PSAK 14, ISO 9001:2015, COSO Internal Control
   ========================================================================== */

.container-tool-page { max-width: 1200px; margin: 0 auto; padding: 0 24px; width: 100%; box-sizing: border-box; }
@media (max-width: 1024px) { .container-tool-page { padding: 0 20px; } }
@media (max-width: 640px) { .container-tool-page { padding: 0 16px; } }

.tool-container {
    width: 100%; margin: 0 auto; padding: 8px 0 32px; box-sizing: border-box;
    color-scheme: light; accent-color: #167c5e;

    --ira-primary: #1a3c34;
    --ira-accent: #167c5e;
    --ira-accent-hover: #116249;
    --ira-accent-light: #e6f4ef;
    --ira-accent-border: #b6dfd0;
    --ira-gold: #c8953e;
    --ira-blue: #0284c7;
    --ira-amber: #d97706;
    --ira-danger: #b3261e;

    --ira-card: var(--bg-card, var(--tool-bg-card, #ffffff));
    --ira-card-alt: var(--bg-subtle, var(--tool-bg-alt, #f8faf9));
    --ira-surface: var(--bg-muted, var(--tool-surface, #f1f4f2));
    --ira-heading: var(--text-primary, var(--tool-text, #0f1f1a));
    --ira-text: var(--text-secondary, var(--tool-text, #263530));
    --ira-text-muted: var(--text-muted, var(--tool-text-muted, #5b6e67));
    --ira-border: var(--border-subtle, var(--tool-border, #e2e5e2));
    --ira-border-strong: var(--border-strong, var(--tool-border-strong, #cbd2ce));
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

[data-theme="dark"] .tool-container {
    color-scheme: dark; accent-color: #28b58b;
    --ira-primary: #14332b; --ira-accent: #28b58b; --ira-accent-hover: #34cba0;
    --ira-accent-light: rgba(40, 181, 139, 0.14); --ira-accent-border: rgba(40, 181, 139, 0.32);
    --ira-gold: #e0ac53; --ira-blue: #38bdf8; --ira-amber: #fbbf24; --ira-danger: #f87171;
    --ira-card: #172521; --ira-card-alt: #1c2c27; --ira-surface: #131f1c;
    --ira-heading: #f0f6f4; --ira-text: #d1dfda; --ira-text-muted: #8ea59d;
    --ira-border: #253832; --ira-border-strong: #334d45;
}

.ira-hero { position: relative; text-align: center; padding: 1.35rem 0 1.15rem; border-bottom: 1px solid var(--ira-border); margin-bottom: 1.25rem; overflow: hidden; }
.ira-hero .tool-icon { display: inline-block; font-size: 1.9rem; line-height: 1; margin-bottom: 0.25rem; }
.ira-watermark { position: absolute; top: -10px; right: -10px; width: 185px; height: 185px; opacity: 0.06; pointer-events: none; color: var(--ira-accent); }
[data-theme="dark"] .ira-watermark { opacity: 0.09; }
.ira-hero h1 { font-size: clamp(1.38rem, 1rem + 1.35vw, 1.96rem); line-height: 1.22; font-weight: 800; color: var(--ira-heading); margin: 0.25rem auto 0.55rem; max-width: 30ch; overflow-wrap: anywhere; }
.ira-hero p { font-size: 0.9rem; line-height: 1.65; color: var(--ira-text-muted); max-width: 74ch; margin: 0 auto; }
.ira-badges { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 0.85rem; }
.ira-chip { font-size: 0.72rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: var(--ira-accent-light); color: var(--ira-accent-hover); border: 1px solid var(--ira-accent-border); }
[data-theme="dark"] .ira-chip { color: #7fe3c2; }

.ira-formula {
    display: flex; flex-wrap: wrap; gap: 0.45rem 1.15rem; align-items: center; justify-content: space-between;
    background: var(--ira-surface); border: 1px solid var(--ira-border); border-radius: 10px;
    padding: 0.7rem 0.95rem; margin-bottom: 1.1rem; font-family: var(--font-mono); font-size: 0.75rem; color: var(--ira-text);
}
.ira-formula .k { color: var(--ira-accent-hover); font-weight: 700; }
[data-theme="dark"] .ira-formula .k { color: #7fe3c2; }

.ira-presets { display: flex; flex-wrap: wrap; gap: 6px; margin: 0.35rem 0 1.1rem; }
.ira-preset {
    font-size: 0.75rem; font-weight: 700; padding: 7px 12px; border-radius: 999px;
    border: 1px solid var(--ira-accent-border); background: var(--ira-accent-light);
    color: var(--ira-accent-hover); cursor: pointer; font-family: inherit;
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
[data-theme="dark"] .ira-preset { color: #7fe3c2; }
.ira-preset:hover, .ira-preset.active { background: var(--ira-accent); color: #ffffff; border-color: var(--ira-accent); transform: translateY(-1px); }

.ira-workspace { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.35rem; align-items: start; }
@media (min-width: 1024px) { .ira-workspace { grid-template-columns: minmax(0, 1.38fr) minmax(0, 1fr); gap: 1.5rem; } }

.ira-panel { background: var(--ira-card); border: 1px solid var(--ira-border); border-radius: 16px; padding: 1.15rem 1.2rem 1.25rem; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03); min-width: 0; }
.ira-result-sticky { min-width: 0; }
@media (min-width: 1024px) { .ira-result-sticky { position: sticky; top: 80px; } }

.ira-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.85rem; }
.ira-panel-head h2 { margin: 0; font-size: 0.96rem; font-weight: 800; color: var(--ira-heading); }
.ira-mini-btn {
    padding: 5px 10px; border-radius: 8px; border: 1px solid var(--ira-border-strong);
    background: var(--ira-card-alt); color: var(--ira-heading); font-size: 0.72rem; font-weight: 700;
    cursor: pointer; font-family: inherit;
}
.ira-mini-btn:hover { border-color: var(--ira-accent); color: var(--ira-accent-hover); }

.ira-fieldset { border: 1px solid var(--ira-border); border-radius: 12px; padding: 0.85rem 0.95rem 0.95rem; margin: 0 0 0.95rem; background: var(--ira-card-alt); min-width: 0; }
.ira-fieldset legend { font-size: 0.76rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ira-accent-hover); padding: 0 0.45rem; }
[data-theme="dark"] .ira-fieldset legend { color: #7fe3c2; }

.ira-grid-2 { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.75rem; }
@media (min-width: 600px) { .ira-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.ira-grid-3 { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.7rem; margin-top: 0.75rem; }
@media (min-width: 600px) { .ira-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.ira-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; margin-bottom: 0.65rem; }
.ira-grid-2 .ira-field, .ira-grid-3 .ira-field { margin-bottom: 0; }
.ira-field label { font-size: 0.77rem; font-weight: 700; color: var(--ira-heading); }
.ira-field small { font-size: 0.7rem; color: var(--ira-text-muted); line-height: 1.4; }
.ira-field input {
    width: 100%; min-height: 42px; padding: 0.5rem 0.7rem; box-sizing: border-box;
    font-family: var(--font-mono); font-size: max(1rem, 1em); font-weight: 600;
    color: var(--ira-heading); background: var(--ira-card); border: 1.5px solid var(--ira-border-strong);
    border-radius: 9px; transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
@media (min-width: 768px) { .ira-field input { font-size: 0.88rem; } }
.ira-field input:focus-visible { outline: 2px solid var(--ira-accent); outline-offset: 1px; border-color: var(--ira-accent); }

.input-terbilang-hint { font-size: 0.72rem; color: var(--ira-accent-hover); font-style: italic; line-height: 1.4; }
[data-theme="dark"] .input-terbilang-hint { color: #7fe3c2; }

.ira-mode-bar { display: grid; grid-template-columns: minmax(0, 1fr); gap: 5px; padding: 4px; background: var(--ira-surface); border: 1px solid var(--ira-border); border-radius: 10px; margin-bottom: 0.8rem; }
@media (min-width: 560px) { .ira-mode-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.ira-mode-tab {
    padding: 0.55rem 0.75rem; border: none; border-radius: 7px; background: transparent;
    color: var(--ira-text-muted); font-size: 0.76rem; font-weight: 800; cursor: pointer; font-family: inherit;
    transition: background 0.15s ease, color 0.15s ease;
}
.ira-mode-tab.active { background: var(--ira-accent); color: #ffffff; }
.ira-mode-tab:focus-visible, .ira-preset:focus-visible, .ira-btn:focus-visible, .ira-mini-btn:focus-visible { outline: 2px solid var(--ira-accent); outline-offset: 2px; }

.ira-chart-card { background: var(--ira-card-alt); border: 1px solid var(--ira-border); border-radius: 12px; padding: 0.85rem 0.95rem; margin-top: 0.2rem; }
.ira-chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.55rem; }
.ira-chart-head h3 { margin: 0; font-size: 0.8rem; font-weight: 800; color: var(--ira-heading); }
.ira-chart-sub { font-size: 0.71rem; color: var(--ira-text-muted); font-family: var(--font-mono); }
#iraChartCanvas { width: 100%; height: 220px; display: block; border-radius: 8px; }

/* Sticky Result Card */
.ira-hero-result { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem; padding: 1rem 1.05rem; border-radius: 12px; color: #ffffff; margin-bottom: 0.85rem; flex-wrap: wrap; }
.ira-hero-result.is-pass { background: linear-gradient(135deg, #167c5e 0%, #0f4c3a 100%); }
.ira-hero-result.is-warn { background: linear-gradient(135deg, #b45309 0%, #78350f 100%); }
.ira-hero-result.is-fail { background: linear-gradient(135deg, #b3261e 0%, #7f1d1d 100%); }
.ira-hero-result .lbl { font-size: 0.67rem; text-transform: uppercase; letter-spacing: 0.05em; opacity: 0.9; font-weight: 700; }
.ira-hero-result .big { font-size: 1.85rem; font-weight: 800; line-height: 1.12; font-family: var(--font-mono); margin: 0.2rem 0; }
.ira-hero-result .sub { font-size: 0.72rem; opacity: 0.92; line-height: 1.4; }
.ira-hero-right { text-align: right; margin-left: auto; }
.ira-pill { display: inline-block; font-size: 0.62rem; font-weight: 800; padding: 3px 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.22); color: #ffffff; letter-spacing: 0.03em; }
.ira-abs-big { font-size: 1.15rem; font-weight: 800; font-family: var(--font-mono); margin-top: 4px; }

.ira-kpi-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.55rem; margin-bottom: 0.8rem; }
.ira-kpi { background: var(--ira-card-alt); border: 1px solid var(--ira-border); border-radius: 10px; padding: 0.62rem 0.7rem; min-width: 0; }
.ira-kpi .k { display: block; font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--ira-text-muted); margin-bottom: 2px; }
.ira-kpi .v { display: block; font-size: 0.92rem; font-weight: 800; font-family: var(--font-mono); color: var(--ira-heading); overflow-wrap: anywhere; }
.ira-kpi .s { display: block; font-size: 0.69rem; color: var(--ira-text-muted); margin-top: 2px; }

.ira-notes { list-style: none; margin: 0 0 0.8rem; padding: 0; display: flex; flex-direction: column; gap: 0.42rem; }
.ira-notes li { font-size: 0.74rem; line-height: 1.5; padding: 0.5rem 0.68rem; border-radius: 8px; background: var(--ira-surface); border: 1px solid var(--ira-border); color: var(--ira-text); }
.ira-notes li.ok { border-left: 3px solid var(--ira-accent); }
.ira-notes li.info { border-left: 3px solid var(--ira-blue); }
.ira-notes li.warn { border-left: 3px solid var(--ira-amber); }
.ira-notes li.bad { border-left: 3px solid var(--ira-danger); background: rgba(179, 38, 30, 0.08); }
[data-theme="dark"] .ira-notes li.bad { background: rgba(248, 113, 113, 0.12); }

.ira-pareto-box { background: var(--ira-card-alt); border: 1px solid var(--ira-border); border-radius: 10px; padding: 0.68rem 0.78rem; margin-bottom: 0.75rem; }
.ira-pareto-title { font-size: 0.74rem; font-weight: 800; color: var(--ira-heading); margin-bottom: 0.45rem; }
.ira-pareto-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.38rem; }
.ira-pareto-item { font-size: 0.72rem; color: var(--ira-text); display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; border-bottom: 1px dashed var(--ira-border); padding-bottom: 0.28rem; }
.ira-pareto-item:last-child { border-bottom: none; padding-bottom: 0; }
.ira-pareto-item strong { color: var(--ira-heading); }
.ira-pareto-item .val { font-family: var(--font-mono); font-weight: 700; color: var(--ira-accent-hover); white-space: nowrap; }
[data-theme="dark"] .ira-pareto-item .val { color: #7fe3c2; }

.ira-rec-box { font-size: 0.75rem; line-height: 1.55; padding: 0.65rem 0.78rem; border-radius: 9px; background: var(--ira-accent-light); border: 1px solid var(--ira-accent-border); color: var(--ira-heading); margin-bottom: 0.85rem; }

.ira-actions { display: flex; flex-direction: column; gap: 0.5rem; }
.ira-actions-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.45rem; }
.ira-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
    padding: 0.58rem 0.72rem; border-radius: 10px; border: 1.5px solid var(--ira-border-strong);
    background: var(--ira-card-alt); color: var(--ira-heading); font-size: 0.77rem; font-weight: 700;
    cursor: pointer; font-family: inherit;
}
.ira-btn:hover { border-color: var(--ira-accent); color: var(--ira-accent-hover); }
[data-theme="dark"] .ira-btn:hover { color: #7fe3c2; }
.ira-btn.primary { background: var(--ira-accent); border-color: var(--ira-accent); color: #ffffff; font-size: 0.83rem; padding: 0.7rem 0.95rem; }
.ira-btn.primary:hover { background: var(--ira-accent-hover); color: #ffffff; }
@media (max-width: 767px) { .ira-btn { min-height: 48px; } }

/* Static Reference Tables */
.ira-ref-wrap { overflow: auto; max-inline-size: 100%; container-type: inline-size; border: 1px solid var(--ira-border); border-radius: 10px; margin: 1.25rem 0 0.85rem; }
.ira-ref-wrap:focus-visible { outline: 2px solid var(--ira-accent); outline-offset: 2px; }
.ira-ref { width: 100%; min-width: 560px; border-collapse: separate; border-spacing: 0; font-size: 0.79rem; }
.ira-ref caption { caption-side: top; text-align: left; padding: 0.6rem 0.75rem; font-size: 0.78rem; font-weight: 800; color: var(--ira-heading); background: var(--ira-card-alt); border-bottom: 1px solid var(--ira-border); }
.ira-ref thead { position: sticky; inset-block-start: 0; z-index: 1; }
.ira-ref th, .ira-ref td { border-bottom: 1px solid var(--ira-border); padding: 0.48rem 0.65rem; text-align: left; color: var(--ira-text); }
.ira-ref thead th { background: var(--ira-surface); font-size: 0.69rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ira-text-muted); font-weight: 800; }
.ira-ref tbody tr:last-child td { border-bottom: none; }

.ira-subhead { font-size: 1rem; font-weight: 800; color: var(--ira-heading); margin: 1.4rem 0 0.7rem; }
.ira-legal { list-style: none; margin: 0 0 1.4rem; padding: 0; display: flex; flex-direction: column; gap: 0.55rem; }
.ira-legal li { font-size: 0.82rem; line-height: 1.65; color: var(--ira-text); background: var(--ira-card-alt); border: 1px solid var(--ira-border); border-left: 3px solid var(--ira-gold); border-radius: 8px; padding: 0.65rem 0.8rem; }
.ira-legal strong { color: var(--ira-heading); }
.ira-disclaimer { font-size: 0.76rem; color: var(--ira-text-muted); line-height: 1.65; margin: 1.2rem 0 0.5rem; padding: 0.75rem 0.95rem; border: 1px solid var(--ira-border); border-radius: 10px; background: var(--ira-card-alt); }

/* Native <dialog> */
.ira-dialog {
    padding: 0; border: 1px solid var(--border-subtle, #e2e5e2); border-radius: 14px;
    background: var(--bg-card, #ffffff); color: var(--text-secondary, #1f2937);
    width: min(94vw, 820px); max-height: 92vh; margin: auto; overflow: hidden; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}
.ira-dialog--sm { width: min(94vw, 540px); }
.ira-dialog[open] { display: flex; flex-direction: column; }
.ira-dialog:modal { overscroll-behavior: contain; }
.ira-dialog::backdrop { background: rgba(10, 22, 18, 0.65); backdrop-filter: blur(3px); overflow: hidden; overscroll-behavior: contain; }
[data-theme="dark"] .ira-dialog { background: #172521; color: #d1dfda; border-color: #253832; color-scheme: dark; }

.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 0.85rem 1.1rem; border-bottom: 1px solid var(--border-subtle, #e2e5e2); }
[data-theme="dark"] .modal-head { border-color: #253832; }
.modal-title { margin: 0; font-size: 0.95rem; font-weight: 800; color: inherit; }
.modal-close { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border-subtle, #cbd5e1); background: transparent; color: inherit; font-size: 1rem; cursor: pointer; }
.modal-body { padding: 1.1rem; overflow-y: auto; flex: 1; }
.modal-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.5rem; padding: 0.8rem 1.1rem; border-top: 1px solid var(--border-subtle, #e2e5e2); }
[data-theme="dark"] .modal-foot { border-color: #253832; }
.modal-label { display: block; font-size: 0.76rem; font-weight: 700; margin-bottom: 4px; color: inherit; }
.modal-input { width: 100%; box-sizing: border-box; padding: 0.55rem 0.7rem; font-size: 0.85rem; font-family: inherit; color: #0f1f1a; background: #f8faf9; border: 1px solid #cbd2ce; border-radius: 8px; }
[data-theme="dark"] .modal-input { background: #1c2c27; color: #f0f6f4; border-color: #334d45; }

.a4-paper { background: #ffffff; color: #0f172a; border: 1px solid #cbd5e1; border-radius: 8px; padding: 1.6rem; font-size: 0.79rem; line-height: 1.5; }
.a4-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; border-bottom: 2.5px solid #1a3c34; padding-bottom: 0.7rem; margin-bottom: 1rem; }
.a4-head h2 { margin: 0; font-size: 1rem; color: #0f172a; }
.a4-head .meta { font-size: 0.72rem; color: #475569; text-align: right; }
.a4-table { width: 100%; border-collapse: collapse; font-size: 0.73rem; margin-bottom: 0.9rem; }
.a4-table th, .a4-table td { border: 1px solid #cbd5e1; padding: 0.36rem 0.5rem; text-align: left; }
.a4-table th { background: #f1f5f9; font-weight: 700; color: #0f172a; }
.a4-sign { display: flex; justify-content: space-between; gap: 2rem; margin-top: 1.5rem; font-size: 0.76rem; color: #334155; }
.a4-sign .col { flex: 1; }
.a4-sign .space { height: 2.8rem; }
.a4-foot { margin-top: 1.2rem; padding-top: 0.5rem; border-top: 1px dashed #cbd5e1; font-size: 0.64rem; color: #64748b; display: flex; justify-content: space-between; gap: 0.8rem; flex-wrap: wrap; }

.toast-container { position: fixed; bottom: 1.25rem; right: 1.25rem; z-index: 2000; display: flex; flex-direction: column; gap: 0.5rem; max-width: min(92vw, 360px); }
.toast-msg { background: #1a3c34; color: #ffffff; padding: 0.7rem 1rem; border-radius: 8px; font-size: 0.82rem; font-weight: 600; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18); }

@media print {
    body * { visibility: hidden; }
    #a4PrintArea, #a4PrintArea * { visibility: visible; }
    #a4PrintArea { position: absolute; left: 0; top: 0; width: 100%; border: none; box-shadow: none; padding: 0; }
}

.tool-faq { margin-top: 0.75rem; }
.tool-faq h3 { font-size: 1.05rem; font-weight: 800; color: var(--ira-heading); margin: 0.25rem 0 1rem; }
.tool-faq-item { border: 1px solid var(--ira-border); border-radius: 10px; margin-bottom: 0.65rem; overflow: hidden; background: var(--ira-card-alt); }
.tool-faq-item.open { border-color: var(--ira-accent); background: var(--ira-card); }
.tool-faq-q { width: 100%; padding: 0.9rem 1.1rem; text-align: left; background: transparent; border: none; cursor: pointer; font-size: 0.88rem; font-weight: 700; color: var(--ira-heading); display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; font-family: inherit; }
.tool-faq-q::after { content: '+'; font-size: 1.2rem; color: var(--ira-accent); }
.tool-faq-item.open .tool-faq-q::after { content: '−'; }
.tool-faq-a { display: none; padding: 0.85rem 1.1rem 1.1rem; font-size: 0.85rem; line-height: 1.68; color: var(--ira-text); border-top: 1px solid var(--ira-border); }
.tool-faq-item.open .tool-faq-a { display: block; }
.tool-faq-a code { background: var(--ira-surface); color: var(--ira-accent-hover); padding: 0.1rem 0.35rem; border-radius: 4px; font-family: var(--font-mono); font-size: 0.79rem; }
[data-theme="dark"] .tool-faq-a code { color: #34d399; }
