:root {
    --green: #1d7a3d;
    --green-dark: #0f4f2d;
    --lime: #a5c73f;
    --ink: #17211b;
    --muted: #6c766f;
    --line: #dfe7e1;
    --panel: #ffffff;
    --bg: #f4f8f5;
    --danger: #b42318;
    --success: #16784a;
    --shadow: 0 18px 50px rgba(23, 33, 27, .09);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(135deg, rgba(29,122,61,.92), rgba(15,79,45,.9)),
        url("https://www.alsetplastik.com.tr/images/slider1.jpg") center / cover;
}

.auth-card {
    width: min(420px, 100%);
    background: rgba(255,255,255,.96);
    border: 1px solid rgba(255,255,255,.7);
    border-radius: 8px;
    padding: 28px;
    box-shadow: var(--shadow);
}

.brand, .side-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    font-weight: 800;
    color: var(--green-dark);
}

.brand img { width: 124px; height: 54px; object-fit: contain; }
.side-brand img { width: 132px; height: 58px; object-fit: contain; }
.side-logo, .print-brand { display: flex; align-items: center; gap: 10px; }
.brand-fallback {
    color: var(--green-dark);
    font-size: 20px;
    font-weight: 900;
    white-space: nowrap;
}

.form-stack { display: grid; gap: 16px; margin-top: 24px; }
label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 700; }
input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    min-height: 44px;
    padding: 10px 12px;
    background: #fff;
    color: var(--ink);
    outline: none;
}
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(29,122,61,.12); }

.primary-btn, .ghost-btn, .icon-btn, .danger-btn, .primary-mini, .danger-mini, .detail-btn {
    border: 0;
    border-radius: 8px;
    min-height: 42px;
    padding: 0 16px;
    font-weight: 800;
}
.primary-btn { background: var(--green); color: #fff; text-decoration: none; display: inline-grid; place-items: center; }
.primary-btn:hover { background: var(--green-dark); }
.ghost-btn { background: #eef6f0; color: var(--green-dark); }
.danger-btn { background: var(--danger); color: #fff; }
.primary-mini, .danger-mini, .detail-btn {
    min-height: 32px;
    padding: 0 10px;
    font-size: 12px;
}
.primary-mini { background: var(--green); color: #fff; }
.danger-mini { background: #fff0ed; color: var(--danger); border: 1px solid #ffd2ca; }
.detail-btn { background: #f6fbf7; color: var(--green-dark); border: 1px solid var(--line); justify-self: start; }
.icon-btn { width: 42px; padding: 0; background: #eef6f0; color: var(--green-dark); display: none; }
.form-message { min-height: 20px; margin: 0; color: var(--danger); font-size: 13px; font-weight: 700; }

.app-shell {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 100vh;
}
.sidebar {
    background: #fff;
    border-right: 1px solid var(--line);
    padding: 20px;
    position: sticky;
    top: 0;
    height: 100vh;
}
.side-brand { justify-content: space-between; margin-bottom: 20px; }
.module-nav { display: grid; gap: 8px; }
.nav-btn {
    width: 100%;
    border: 0;
    background: transparent;
    color: var(--muted);
    min-height: 44px;
    border-radius: 8px;
    padding: 0 12px;
    text-align: left;
    font-weight: 800;
}
.nav-btn.active, .nav-btn:hover { background: #eef6f0; color: var(--green-dark); }

.workspace { min-width: 0; padding: 24px; }
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}
.eyebrow { color: var(--green); font-weight: 900; margin: 0 0 4px; text-transform: uppercase; font-size: 12px; }
h1 { margin: 0; font-size: 28px; line-height: 1.15; }
.user-chip { display: flex; align-items: center; gap: 12px; color: var(--muted); font-weight: 800; }

.content { display: grid; gap: 18px; }
.stat-grid, .kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.data-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.module-home {
    display: grid;
    gap: 18px;
}
.module-home-head {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    box-shadow: 0 10px 30px rgba(23, 33, 27, .05);
}
.module-home-head h2 {
    margin: 0 0 6px;
    font-size: 22px;
    color: var(--green-dark);
}
.module-home-head p {
    margin: 0;
    color: var(--muted);
    font-weight: 750;
    line-height: 1.45;
}
.module-card-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}
.module-card {
    min-height: 132px;
    display: grid;
    align-content: start;
    gap: 10px;
    text-align: left;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    color: var(--ink);
    box-shadow: 0 10px 30px rgba(23, 33, 27, .05);
}
.module-card:hover {
    border-color: rgba(29, 122, 61, .45);
    box-shadow: 0 16px 34px rgba(23, 33, 27, .08);
    transform: translateY(-1px);
}
.module-card strong {
    color: var(--green-dark);
    font-size: 17px;
}
.module-card span {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
    font-weight: 750;
}
.empty-state {
    margin: 0;
    color: var(--muted);
    font-weight: 800;
}
.stat-card, .kpi-card, .panel, .table-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(23, 33, 27, .05);
}
.stat-card, .kpi-card { padding: 18px; }
.kpi-card {
    display: grid;
    gap: 12px;
    min-height: 142px;
    align-content: space-between;
}
.stat-card span, .kpi-card span { display: block; color: var(--muted); font-size: 13px; font-weight: 800; }
.stat-card strong, .kpi-card strong { display: block; margin-top: 4px; font-size: 32px; color: var(--green-dark); }
.panel { padding: 18px; }
.panel h2 { margin: 0 0 14px; font-size: 18px; }
.table-card { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { padding: 13px 14px; border-bottom: 1px solid var(--line); text-align: left; font-size: 14px; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; background: #fbfdfb; }
tr:last-child td { border-bottom: 0; }
tr.cancelled-row td {
    background: #fff3f1;
    color: #7a241b;
}
tr.cancelled-row td:first-child {
    box-shadow: inset 4px 0 0 var(--danger);
}
.badge { display: inline-flex; align-items: center; min-height: 26px; padding: 0 9px; border-radius: 999px; background: #eef6f0; color: var(--green-dark); font-weight: 900; font-size: 12px; white-space: nowrap; }
.status-pending, .status-planned, .status-waiting { background: #fff8e6; color: #8a5a00; }
.status-in_progress, .status-active, .status-reserved, .status-held { background: #e9f3ff; color: #145a9e; }
.status-completed, .status-approved, .status-available, .status-done { background: #eaf7ef; color: var(--success); }
.status-cancelled, .status-rejected, .status-out { background: #fff0ed; color: var(--danger); }
.ghost-link { color: var(--green-dark); font-weight: 900; text-decoration: none; }

.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: end; }
.form-grid .wide { grid-column: span 2; }
.form-grid .full { grid-column: 1 / -1; }
select[multiple] { min-height: 110px; }
.button-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.inline-qty {
    width: 88px;
    min-height: 32px;
    padding: 5px 8px;
    font-weight: 900;
}
.detail-stack {
    display: grid;
    gap: 10px;
}
.detail-stack p {
    margin: 0;
    color: var(--ink);
    font-weight: 750;
    line-height: 1.45;
}
.scanner-layout {
    display: grid;
    grid-template-columns: minmax(260px, 420px) 1fr;
    gap: 16px;
    align-items: stretch;
    margin-bottom: 16px;
}
.barcode-input {
    min-height: 54px;
    font-size: 20px;
    font-weight: 900;
    letter-spacing: 0;
}
.scan-result, .camera-mount {
    min-height: 118px;
    border: 1px dashed var(--line);
    border-radius: 8px;
    background: #fbfdfb;
    padding: 14px;
    display: grid;
    align-content: center;
    gap: 8px;
    color: var(--muted);
    font-weight: 800;
}
.scan-result strong { color: var(--green-dark); font-size: 18px; }
.scan-result span { display: block; }
.camera-mount {
    margin-top: 12px;
    min-height: 180px;
    place-items: center;
    text-align: center;
}
.notice, .toast {
    border-radius: 8px;
    padding: 12px 14px;
    font-weight: 800;
    font-size: 14px;
}
.notice.success, .toast.success { background: #eaf7ef; color: var(--success); }
.notice.danger, .toast.danger { background: #fff0ed; color: var(--danger); }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 20; box-shadow: var(--shadow); background: #fff; }
.permission-grid { display: grid; grid-template-columns: repeat(6, minmax(96px, 1fr)); gap: 8px; }
.permission-cell { display: flex; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 8px; padding: 9px; font-size: 12px; font-weight: 800; color: var(--muted); }
.permission-cell input { width: auto; min-height: auto; }
.report-head, .report-preview-title {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}
.report-head h2, .report-preview-title h2 { margin: 0; }
.report-head p { margin: 6px 0 0; color: var(--muted); font-weight: 750; }
.report-preview {
    display: grid;
    gap: 14px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    box-shadow: 0 10px 30px rgba(23, 33, 27, .05);
}
.report-preview-title {
    border-bottom: 2px solid var(--green-dark);
    padding-bottom: 12px;
}
.report-preview-title span {
    color: var(--green);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0;
}
.report-preview-title strong { color: var(--muted); font-size: 13px; }
.report-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}
.report-summary-grid article {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: #fbfdfb;
}
.report-summary-grid span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
}
.report-summary-grid strong {
    display: block;
    margin-top: 4px;
    color: var(--green-dark);
    font-size: 22px;
}
.report-filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.report-filter-row span {
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 7px 10px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    background: #fff;
}
.report-preview-frame {
    width: 100%;
    min-height: min(78vh, 860px);
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(15, 33, 23, .44);
}
.modal {
    width: min(860px, 100%);
    max-height: min(760px, calc(100vh - 36px));
    overflow: hidden;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    background: #fff;
    border-radius: 8px;
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}
.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
}
.modal-head h2 { margin: 0; font-size: 20px; }
.modal-close { display: inline-grid; place-items: center; min-height: 36px; width: 36px; font-size: 22px; }
.modal-body {
    padding: 18px;
    overflow: auto;
}
.modal-copy {
    margin: 0;
    white-space: pre-line;
    color: var(--ink);
    font-weight: 750;
    line-height: 1.5;
}
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 18px;
    border-top: 1px solid var(--line);
    background: #fbfdfb;
}

@media (max-width: 980px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; padding: 14px; }
    .icon-btn { display: inline-grid; place-items: center; }
    .module-nav.collapsed { display: none; }
    .workspace { padding: 16px; }
    .stat-grid, .kpi-grid, .data-grid, .module-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .scanner-layout { grid-template-columns: 1fr; }
}

.print-body { background: #fff; color: #000; min-height: auto; }
.label-sheet {
    width: 100mm;
    min-height: 145mm;
    margin: 0 auto;
    padding: 7mm;
    background: #fff;
    border: 2px solid #111;
}
.label-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8mm;
    border-bottom: 2px solid #111;
    padding-bottom: 4mm;
}
.label-head img { width: 38mm; height: 16mm; object-fit: contain; }
.label-head strong { font-size: 22pt; color: #111; }
.label-table { min-width: 0; margin-top: 4mm; border: 2px solid #111; }
.label-table th, .label-table td {
    border: 1px solid #111;
    color: #000;
    font-size: 15pt;
    padding: 3mm;
}
.label-table th { width: 32mm; background: #f3f3f3; font-size: 13pt; }
.label-table td.big { font-size: 28pt; font-weight: 900; }
.label-table .roll-no { font-size: 21pt; font-weight: 900; word-break: break-all; }
.label-table .roll-no small { display: block; margin-top: 2mm; font-size: 11pt; font-weight: 800; }
.barcode-bars {
    display: flex;
    align-items: stretch;
    justify-content: center;
    height: 30mm;
    margin-top: 5mm;
    padding: 2mm;
    background: #fff;
    border: 1px solid #111;
    overflow: hidden;
}
.barcode-bars .bar { display: block; flex: 0 0 auto; height: 100%; background: #000; }
.barcode-bars .space { display: block; flex: 0 0 auto; height: 100%; background: #fff; }
.barcode-number { margin-top: 2mm; text-align: center; font-size: 17pt; font-weight: 900; color: #000; letter-spacing: 0; }
.label-error {
    margin-top: 10mm;
    border: 2px solid #111;
    padding: 8mm;
    color: #111;
    text-align: center;
}
.label-error strong { display: block; font-size: 18pt; }
.label-error p { margin: 4mm 0 0; font-size: 13pt; font-weight: 800; }
.delivery-sheet { width: 210mm; min-height: 297mm; margin: 0 auto; padding: 16mm; background: #fff; }
.delivery-head { display: flex; align-items: center; justify-content: space-between; border-bottom: 3px solid var(--green-dark); padding-bottom: 8mm; margin-bottom: 8mm; }
.delivery-head img { width: 48mm; height: 20mm; object-fit: contain; }
.delivery-head h1 { color: var(--green-dark); font-size: 28pt; }
.delivery-note { margin-top: 10mm; border: 1px solid #111; min-height: 35mm; padding: 5mm; }
.report-print-body { background: #eef3ef; }
.report-print-page {
    width: 210mm;
    min-height: 297mm;
    margin: 0 auto;
    padding: 14mm;
    background: #fff;
    color: #111;
}
.print-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8mm;
    padding: 8px 10px;
    border: 1px solid #cfd8d1;
    border-radius: 8px;
    background: #f5faf6;
    color: #34433a;
    font-size: 12px;
    font-weight: 800;
}
.print-actions button {
    border: 0;
    border-radius: 8px;
    min-height: 36px;
    padding: 0 14px;
    background: var(--green);
    color: #fff;
    font-weight: 900;
}
.report-print-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12mm;
    border-bottom: 3px solid var(--green-dark);
    padding-bottom: 7mm;
}
.report-print-header img { width: 48mm; height: 20mm; object-fit: contain; }
.report-print-header > div:last-child { text-align: right; }
.report-print-header strong { color: var(--green-dark); font-size: 12pt; }
.report-print-header h1 { margin-top: 2mm; color: #111; font-size: 22pt; }
.report-print-header p { margin: 2mm 0 0; color: #4a574f; font-weight: 800; }
.report-print-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 2mm 6mm;
    margin: 7mm 0;
    color: #34433a;
    font-size: 10pt;
}
.report-print-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 3mm;
    margin-bottom: 7mm;
}
.report-print-summary article {
    border: 1px solid #cfd8d1;
    border-left: 4px solid var(--green);
    padding: 3mm;
    background: #f7fbf8;
}
.report-print-summary span {
    display: block;
    color: #59655e;
    font-size: 9pt;
    font-weight: 800;
}
.report-print-summary strong {
    display: block;
    margin-top: 1mm;
    color: var(--green-dark);
    font-size: 15pt;
}
.report-print-table {
    min-width: 0;
    border: 1px solid #111;
}
.report-print-table th, .report-print-table td {
    border: 1px solid #cfd8d1;
    padding: 2.4mm;
    color: #111;
    font-size: 8.5pt;
    vertical-align: top;
}
.report-print-table th {
    background: #eef6f0;
    color: var(--green-dark);
}
.report-print-table tr.cancelled-row td {
    background: #fff1ef;
    color: #8b2018;
    opacity: .78;
}
.cancel-label {
    display: block;
    margin-top: 1.5mm;
    font-size: 7.5pt;
    font-weight: 900;
    color: var(--danger);
}
@media print {
    .print-body { margin: 0; }
    .label-sheet, .delivery-sheet, .report-print-page { box-shadow: none; margin: 0; }
    .print-actions { display: none; }
    @page { margin: 8mm; }
}

@media (max-width: 620px) {
    .topbar, .user-chip { align-items: flex-start; flex-direction: column; }
    .stat-grid, .kpi-grid, .data-grid, .form-grid, .module-card-grid { grid-template-columns: 1fr; }
    .form-grid .wide { grid-column: auto; }
    .report-head, .report-preview-title { flex-direction: column; }
    .report-summary-grid { grid-template-columns: 1fr; }
    .permission-grid { grid-template-columns: 1fr 1fr; }
    h1 { font-size: 24px; }
    .auth-card, .panel { padding: 16px; }
    .workspace { padding: 12px; }
    table { min-width: 640px; }
    .modal-actions { flex-direction: column-reverse; }
    .modal-actions button { width: 100%; }
}
