/* ============================================================
   SANITEC Rental — Mobile-First Design System
   iPhone-primary, responsive up to desktop
   Brand: #4472C4 (SANITEC Blue)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=DM+Mono:wght@400;500&display=swap');

/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
    /* Brand */
    --blue:          #4472C4;
    --blue-dark:     #2f57a8;
    --blue-light:    #edf1fb;
    --blue-mid:      #c5d3f0;

    /* Sidebar */
    --sidebar-bg:    #1a2744;
    --sidebar-text:  #c8d4ee;
    --sidebar-w:     220px;

    /* Surface */
    --bg:            #f0f4fc;
    --surface:       #ffffff;
    --surface-2:     #f8fafd;
    --border:        #e2e8f4;

    /* Text */
    --text:          #1a2744;
    --text-2:        #4a5568;
    --text-muted:    #8898aa;

    /* Semantic */
    --green:         #16a34a;
    --green-bg:      #dcfce7;
    --red:           #dc2626;
    --red-bg:        #fee2e2;
    --amber:         #d97706;
    --amber-bg:      #fef3c7;
    --purple:        #7c3aed;
    --purple-bg:     #ede9fe;

    /* Spacing */
    --gap:           16px;
    --gap-sm:        8px;
    --gap-lg:        24px;

    /* Shape */
    --r:             14px;
    --r-sm:          8px;
    --r-xs:          6px;
    --r-full:        100px;

    /* Shadow */
    --shadow-xs:     0 1px 3px rgba(26,39,68,.06);
    --shadow-sm:     0 2px 8px rgba(26,39,68,.08);
    --shadow-md:     0 4px 20px rgba(26,39,68,.12);
    --shadow-lg:     0 8px 32px rgba(26,39,68,.16);

    /* Touch */
    --touch:         48px;
    --touch-sm:      40px;

    /* Typography */
    --font:          'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono:     'DM Mono', 'SF Mono', monospace;

    /* Bottom nav height (mobile) */
    --bottom-nav-h:  68px;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

html, body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

body {
    font-family:  var(--font);
    background:   var(--bg);
    color:        var(--text);
    font-size:    15px;
    line-height:  1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--blue-dark); }

img { max-width: 100%; }

/* ============================================================
   MATERIAL SYMBOLS
   ============================================================ */
.material-symbols-outlined {
    font-family:             'Material Symbols Outlined';
    font-weight:             normal;
    font-style:              normal;
    font-size:               22px;
    line-height:             1;
    letter-spacing:          normal;
    text-transform:          none;
    display:                 inline-flex;
    align-items:             center;
    justify-content:         center;
    white-space:             nowrap;
    word-wrap:               normal;
    direction:               ltr;
    -webkit-font-smoothing:  antialiased;
    vertical-align:          middle;
    user-select:             none;
    flex-shrink:             0;
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}
.material-symbols-outlined.ms-filled { font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24; }
.material-symbols-outlined.ms-sm  { font-size: 16px; }
.material-symbols-outlined.ms-md  { font-size: 20px; }
.material-symbols-outlined.ms-lg  { font-size: 26px; }
.material-symbols-outlined.ms-xl  { font-size: 32px; }
.material-symbols-outlined.ms-2x  { font-size: 40px; }
.material-symbols-outlined.ms-3x  { font-size: 52px; }

/* ============================================================
   LAYOUT — SIDEBAR (desktop ≥ 992px)
   ============================================================ */
#sidebar {
    position:       fixed;
    top:            0;
    left:           0;
    width:          var(--sidebar-w);
    height:         100vh;
    height:         100dvh;
    background:     var(--sidebar-bg);
    display:        flex;
    flex-direction: column;
    z-index:        200;
    overflow-y:     auto;
    transition:     transform .28s cubic-bezier(.4,0,.2,1);
}

.sidebar-logo {
    padding:       22px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,.07);
}
.sidebar-logo img {
    width:  130px;
    filter: brightness(0) invert(1);
    display: block;
}
.sidebar-logo .tagline {
    font-size:      9px;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    color:          rgba(200,212,238,.45);
    margin-top:     5px;
}

.sidebar-user {
    padding:       14px 20px;
    border-bottom: 1px solid rgba(255,255,255,.06);
    display:       flex;
    align-items:   center;
    gap:           10px;
}
.sidebar-avatar {
    width:           36px;
    height:          36px;
    border-radius:   50%;
    background:      var(--blue);
    display:         flex;
    align-items:     center;
    justify-content: center;
    font-size:       13px;
    font-weight:     600;
    color:           #fff;
    flex-shrink:     0;
    letter-spacing:  .5px;
}
.sidebar-user-name  { font-size: 13px; font-weight: 600; color: #fff; line-height: 1.2; }
.sidebar-user-role  { font-size: 11px; color: var(--sidebar-text); opacity: .65; }

.sidebar-nav        { padding: 10px 8px; flex: 1; }

.nav-section-label {
    font-size:      10px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color:          rgba(200,212,238,.35);
    padding:        10px 12px 4px;
}

.sidebar-nav .nav-link {
    display:         flex;
    align-items:     center;
    gap:             10px;
    padding:         10px 12px;
    border-radius:   var(--r-sm);
    color:           var(--sidebar-text);
    font-size:       13.5px;
    font-weight:     400;
    text-decoration: none;
    transition:      background .15s, color .15s;
    margin-bottom:   2px;
    min-height:      var(--touch-sm);
}
.sidebar-nav .nav-link .material-symbols-outlined { font-size: 20px; opacity: .75; }
.sidebar-nav .nav-link:hover  { background: rgba(68,114,196,.22); color: #fff; }
.sidebar-nav .nav-link:hover  .material-symbols-outlined { opacity: 1; }
.sidebar-nav .nav-link.active { background: var(--blue); color: #fff; font-weight: 500; }
.sidebar-nav .nav-link.active .material-symbols-outlined { opacity: 1; }

.sidebar-footer {
    padding:    10px 8px 12px;
    border-top: 1px solid rgba(255,255,255,.06);
}

/* ============================================================
   LAYOUT — MAIN CONTENT
   ============================================================ */
#main-content {
    margin-left: var(--sidebar-w);
    min-height:  100vh;
}

/* ---- Topbar ---- */
.topbar {
    position:      sticky;
    top:           0;
    z-index:       100;
    background:    var(--surface);
    border-bottom: 1px solid var(--border);
    padding:       0 28px;
    height:        60px;
    display:       flex;
    align-items:   center;
    justify-content: space-between;
    gap:           12px;
}
.topbar-title {
    font-size:   17px;
    font-weight: 600;
    color:       var(--text);
    line-height: 1.2;
}
.topbar-title small {
    display:    block;
    font-size:  11px;
    font-weight:400;
    color:      var(--text-muted);
    margin-top: 1px;
}
.topbar-actions { display: flex; align-items: center; gap: 8px; }

/* ---- Page content ---- */
.page-content { padding: 24px 28px; }

/* ---- Sidebar overlay ---- */
#sidebar-overlay {
    display:    none;
    position:   fixed;
    inset:      0;
    background: rgba(0,0,0,.45);
    z-index:    199;
    backdrop-filter: blur(2px);
}
#sidebar-overlay.show { display: block; }

/* ============================================================
   BOTTOM NAV (mobile < 992px)
   ============================================================ */
#bottom-nav {
    display:         none;
    position:        fixed;
    bottom:          0;
    left:            0;
    right:           0;
    background:      rgba(255,255,255,0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top:      1px solid rgba(0,0,0,0.08);
    z-index:         200;
    /* iOS safe area */
    padding-bottom:  env(safe-area-inset-bottom, 0px);
    box-shadow:      0 -1px 0 rgba(0,0,0,0.06), 0 -8px 24px rgba(26,39,68,0.08);
}
.bottom-nav-inner {
    display:         flex;
    height:          56px;
    align-items:     stretch;
    min-width:       100%;
    width:           100%;
}
.bottom-nav-item {
    flex:            1;
    display:         flex;
    flex-direction:  column;
    align-items:     center;
    justify-content: center;
    gap:             2px;
    text-decoration: none;
    color:           #94a3b8;
    font-size:       10px;
    font-weight:     500;
    letter-spacing:  .1px;
    transition:      color .15s;
    -webkit-tap-highlight-color: transparent;
    position:        relative;
    padding:         6px 4px 4px;
}
.bottom-nav-item .material-symbols-outlined {
    font-size:  24px;
    transition: font-variation-settings .15s;
    font-variation-settings: 'FILL' 0, 'wght' 300, 'GRAD' 0, 'opsz' 24;
}
.bottom-nav-item span.label {
    font-size:   10px;
    font-weight: 500;
    line-height: 1;
}
.bottom-nav-item.active {
    color: var(--blue);
}
.bottom-nav-item.active .material-symbols-outlined {
    font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24;
}

/* Center "Neu" button — pill style */
.bottom-nav-item.nav-accent {
    color: var(--blue);
}
.bottom-nav-accent-wrap {
    width:           48px;
    height:          48px;
    border-radius:   50%;
    background:      var(--blue);
    display:         flex;
    align-items:     center;
    justify-content: center;
    box-shadow:      0 4px 14px rgba(68,114,196,0.45);
    margin-bottom:   2px;
}
.bottom-nav-accent-wrap .material-symbols-outlined {
    font-size:  26px;
    color:      #fff;
    font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24;
}

.bottom-nav-badge {
    position:        absolute;
    top:             4px;
    left:            calc(50% + 8px);
    background:      var(--red);
    color:           #fff;
    font-size:       9px;
    font-weight:     700;
    min-width:       15px;
    height:          15px;
    border-radius:   8px;
    display:         flex;
    align-items:     center;
    justify-content: center;
    padding:         0 3px;
    border:          2px solid #fff;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background:    var(--surface);
    border:        1px solid var(--border);
    border-radius: var(--r);
    box-shadow:    var(--shadow-xs);
    overflow:      hidden;
}
.card-header {
    padding:       14px 20px;
    border-bottom: 1px solid var(--border);
    font-size:     14px;
    font-weight:   600;
    color:         var(--text);
    background:    var(--surface);
    display:       flex;
    align-items:   center;
    gap:           8px;
}
.card-body { padding: 20px; }

/* ---- Stat cards ---- */
.stat-card {
    background:      var(--surface);
    border:          1px solid var(--border);
    border-radius:   var(--r);
    padding:         20px;
    box-shadow:      var(--shadow-xs);
    display:         flex;
    align-items:     flex-start;
    justify-content: space-between;
    gap:             12px;
    text-decoration: none;
    color:           inherit;
    transition:      box-shadow .2s, transform .15s;
    -webkit-tap-highlight-color: transparent;
    cursor:          pointer;
}
.stat-card:hover  { box-shadow: var(--shadow-md); color: inherit; }
.stat-card:active { transform: scale(.98); }

.stat-icon {
    width:           48px;
    height:          48px;
    border-radius:   var(--r-sm);
    display:         flex;
    align-items:     center;
    justify-content: center;
    flex-shrink:     0;
}
.stat-icon .material-symbols-outlined { font-size: 24px; }

.stat-label {
    font-size:      11px;
    font-weight:    600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color:          var(--text-muted);
    margin-bottom:  4px;
    white-space:    nowrap;
}
.stat-value {
    font-size:   26px;
    font-weight: 700;
    line-height: 1;
    color:       var(--text);
    white-space: nowrap;
}
.stat-sub {
    font-size:  12px;
    color:      var(--text-muted);
    margin-top: 4px;
    white-space:nowrap;
}

/* ============================================================
   TABLES
   ============================================================ */
.table-sanitec {
    font-size:    14px;
    border-color: var(--border);
    width:        100%;
    margin:       0;
}
.table-sanitec thead th {
    background:     var(--surface-2);
    border-bottom:  1px solid var(--border);
    font-size:      11px;
    font-weight:    600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color:          var(--text-muted);
    padding:        11px 16px;
    white-space:    nowrap;
}
.table-sanitec tbody td {
    padding:        13px 16px;
    border-color:   var(--border);
    vertical-align: middle;
}
.table-sanitec tbody tr { transition: background .12s; }
.table-sanitec tbody tr:hover { background: var(--blue-light); }
.row-overdue { background: rgba(220,38,38,.05) !important; }
.row-warning { background: rgba(217,119,6,.05) !important; }

/* ---- Mobile list cards (replaces table on small screens) ---- */
.list-card {
    background:    var(--surface);
    border:        1px solid var(--border);
    border-radius: var(--r);
    padding:       16px;
    display:       flex;
    gap:           12px;
    align-items:   flex-start;
    text-decoration: none;
    color:         inherit;
    transition:    box-shadow .15s, transform .1s;
    -webkit-tap-highlight-color: transparent;
}
.list-card:active { transform: scale(.99); }
.list-card + .list-card { border-top: none; border-radius: 0; }
.list-card:first-child { border-radius: var(--r) var(--r) 0 0; }
.list-card:last-child  { border-radius: 0 0 var(--r) var(--r); }
.list-card:only-child  { border-radius: var(--r); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    font-family:  var(--font);
    font-size:    14px;
    font-weight:  500;
    border-radius:var(--r-sm);
    padding:      10px 18px;
    min-height:   var(--touch-sm);
    display:      inline-flex;
    align-items:  center;
    gap:          6px;
    transition:   background .15s, box-shadow .15s, transform .1s;
    -webkit-tap-highlight-color: transparent;
    white-space:  nowrap;
}
.btn:active     { transform: scale(.97); }
.btn-sm         { font-size: 13px; padding: 7px 14px; min-height: 36px; }
.btn-lg         { font-size: 15px; padding: 13px 24px; min-height: var(--touch); }

.btn-primary    { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); color: #fff; }

.btn-outline-primary { color: var(--blue); border-color: var(--blue); background: transparent; }
.btn-outline-primary:hover { background: var(--blue); color: #fff; }

.btn-outline-secondary { color: var(--text-2); border-color: var(--border); background: var(--surface); }
.btn-outline-secondary:hover { background: var(--surface-2); color: var(--text); }

.btn-outline-danger { color: var(--red); border-color: #fca5a5; background: transparent; }
.btn-outline-danger:hover { background: var(--red); color: #fff; border-color: var(--red); }

.btn-outline-success { color: var(--green); border-color: #86efac; background: transparent; }
.btn-outline-success:hover { background: var(--green); color: #fff; border-color: var(--green); }

.btn-outline-warning { color: var(--amber); border-color: #fcd34d; background: transparent; }
.btn-outline-warning:hover { background: var(--amber); color: #fff; border-color: var(--amber); }

/* Icon-only button */
.btn-icon {
    width:           var(--touch-sm);
    height:          var(--touch-sm);
    padding:         0;
    border-radius:   var(--r-sm);
    display:         inline-flex;
    align-items:     center;
    justify-content: center;
}
.btn-icon.btn-sm { width: 34px; height: 34px; }
.btn-icon.btn-lg { width: var(--touch); height: var(--touch); }

/* FAB — Floating Action Button */
.fab {
    position:        fixed;
    bottom:          calc(var(--bottom-nav-h) + 16px);
    right:           20px;
    width:           56px;
    height:          56px;
    border-radius:   50%;
    background:      var(--blue);
    color:           #fff;
    border:          none;
    box-shadow:      var(--shadow-lg);
    display:         none; /* shown only mobile */
    align-items:     center;
    justify-content: center;
    z-index:         150;
    cursor:          pointer;
    transition:      transform .15s, box-shadow .15s;
    -webkit-tap-highlight-color: transparent;
}
.fab:active { transform: scale(.92); }
.fab .material-symbols-outlined { font-size: 26px; }

/* ============================================================
   FORMS
   ============================================================ */
.form-label {
    font-size:    13.5px;
    font-weight:  500;
    color:        var(--text);
    margin-bottom:6px;
    display:      block;
}

.form-control, .form-select {
    font-family:  var(--font);
    font-size:    15px;
    border:       1px solid var(--border);
    border-radius:var(--r-sm);
    color:        var(--text);
    padding:      10px 14px;
    height:       auto;
    min-height:   var(--touch-sm);
    background:   var(--surface);
    width:        100%;
    transition:   border-color .15s, box-shadow .15s;
    -webkit-appearance: none;
    appearance:   none;
}
.form-control:focus, .form-select:focus {
    border-color: var(--blue);
    box-shadow:   0 0 0 3px rgba(68,114,196,.14);
    outline:      none;
}
.form-control::placeholder { color: var(--text-muted); }

.input-group { display: flex; }
.input-group .form-control { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.input-group .btn:last-child { border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.input-group-text {
    background:    var(--surface-2);
    border:        1px solid var(--border);
    padding:       10px 14px;
    font-size:     14px;
    color:         var(--text-muted);
    display:       flex;
    align-items:   center;
}
.input-group .input-group-text:first-child { border-radius: var(--r-sm) 0 0 var(--r-sm); border-right: none; }
.input-group .input-group-text:last-child  { border-radius: 0 var(--r-sm) var(--r-sm) 0; border-left: none; }

.form-check-input { width: 18px; height: 18px; cursor: pointer; }
.form-check-label { font-size: 14px; cursor: pointer; margin-left: 4px; }
.form-text        { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
    font-family:  var(--font);
    font-size:    11.5px;
    font-weight:  500;
    padding:      4px 10px;
    border-radius:var(--r-full);
    display:      inline-flex;
    align-items:  center;
    gap:          4px;
    white-space:  nowrap;
}

/* ---- Status badges ---- */
.badge-active   { background: #dbeafe; color: #1d4ed8; }
.badge-returned { background: var(--green-bg); color: var(--green); }
.badge-overdue  { background: var(--red-bg); color: var(--red); }
.badge-cancelled{ background: #f1f5f9; color: #64748b; }
.badge-free     { background: var(--green-bg); color: var(--green); }
.badge-defective{ background: var(--amber-bg); color: var(--amber); }

/* ---- Days badge ---- */
.days-badge {
    display:     inline-flex;
    align-items: center;
    gap:         4px;
    font-size:   12px;
    font-weight: 600;
    padding:     4px 10px;
    border-radius:var(--r-full);
}
.days-badge.overdue  { background: var(--red-bg);   color: var(--red); }
.days-badge.warning  { background: var(--amber-bg); color: var(--amber); }
.days-badge.ok       { background: var(--green-bg); color: var(--green); }
.days-badge.returned { background: #f1f5f9; color: #64748b; }

/* ============================================================
   ART.NR CHIP
   ============================================================ */
.art-nr {
    font-family:  var(--font-mono);
    font-size:    11.5px;
    background:   var(--blue-light);
    color:        var(--blue);
    padding:      2px 8px;
    border-radius:var(--r-xs);
    white-space:  nowrap;
    display:      inline-block;
}

/* ============================================================
   MACHINE IMAGES
   ============================================================ */
.machine-thumb {
    width:        48px;
    height:       48px;
    object-fit:   cover;
    border-radius:var(--r-sm);
    border:       1px solid var(--border);
    flex-shrink:  0;
}
.machine-thumb-placeholder {
    width:           48px;
    height:          48px;
    border-radius:   var(--r-sm);
    border:          1px solid var(--border);
    background:      var(--blue-light);
    display:         flex;
    align-items:     center;
    justify-content: center;
    color:           var(--blue);
    flex-shrink:     0;
}
.machine-thumb-placeholder .material-symbols-outlined { font-size: 22px; }

/* ============================================================
   RISK INDICATOR
   ============================================================ */
.risk-dot {
    width:         8px;
    height:        8px;
    border-radius: 50%;
    display:       inline-block;
    flex-shrink:   0;
}
.risk-dot.low    { background: var(--green); }
.risk-dot.medium { background: var(--amber); }
.risk-dot.high   { background: var(--red); }

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
    border:        none;
    border-radius: var(--r-sm);
    font-size:     14px;
    border-left:   4px solid;
    padding:       12px 16px;
}
.alert-success { background: var(--green-bg); border-left-color: var(--green); color: #15803d; }
.alert-danger  { background: var(--red-bg);   border-left-color: var(--red);   color: var(--red); }
.alert-warning { background: var(--amber-bg); border-left-color: var(--amber); color: var(--amber); }
.alert-info    { background: #dbeafe; border-left-color: var(--blue); color: #1d4ed8; }
.alert-light   { background: var(--surface-2); border-left-color: var(--border); color: var(--text-2); }

/* ============================================================
   MODALS
   ============================================================ */
.modal-content {
    border:        none;
    border-radius: var(--r);
    box-shadow:    var(--shadow-lg);
}
.modal-header {
    border-bottom: 1px solid var(--border);
    padding:       16px 20px;
}
.modal-footer {
    border-top:    1px solid var(--border);
    padding:       14px 20px;
    gap:           8px;
}
.modal-body { padding: 20px; }
.modal-title { font-size: 16px; font-weight: 600; }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
    min-height:      100vh;
    background:      var(--sidebar-bg);
    display:         flex;
    align-items:     center;
    justify-content: center;
    padding:         20px;
}
.login-card {
    background:    var(--surface);
    border-radius: var(--r);
    padding:       36px 32px;
    width:         100%;
    max-width:     400px;
    box-shadow:    var(--shadow-lg);
}
.login-logo-wrap {
    background:    var(--sidebar-bg);
    border-radius: var(--r-sm);
    padding:       20px 28px;
    text-align:    center;
    margin-bottom: 28px;
}
.login-logo-wrap img {
    width:  150px;
    filter: brightness(0) invert(1);
}
.login-tagline {
    font-size:      9px;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    color:          rgba(200,212,238,.5);
    margin-top:     6px;
}

/* items-mobile: mobilde göster, desktop'ta gizle */
#items-mobile { display: block; }
@media (min-width: 992px) {
    #items-mobile { display: none !important; }
}

/* items-body tablo satırları: desktop'ta göster, mobilde gizle (hidden input'lar çalışır) */
@media (max-width: 991.98px) {
    #items-body tr.item-row { visibility: hidden; height: 0; overflow: hidden; }
    #items-body tr.item-row td { padding: 0; border: none; }
    #items-body tr.item-row input[type="hidden"] { display: block; }
    #items-table-wrap thead { display: none; }
    #items-table-wrap tfoot { display: none; }
    #items-table-wrap table { margin: 0 !important; }
}

/* Gerät arama header — sadece desktop'ta sticky */
@media (min-width: 992px) {
    .geraet-header-sticky {
        position:      sticky;
        top:           60px;
        z-index:       100;
        background:    var(--surface);
        border-radius: var(--r) var(--r) 0 0;
    }
}

/* machine-results — mobilde fixed bottom sheet, DOM'u etkilemez */
@media (max-width: 991.98px) {
    #machine-results:not(:empty) {
        position:        fixed;
        bottom:          calc(56px + env(safe-area-inset-bottom, 0px));
        left:            0;
        right:           0;
        max-height:      55vh;
        overflow-y:      auto;
        background:      var(--surface);
        border-top:      2px solid var(--blue);
        border-radius:   var(--r) var(--r) 0 0;
        box-shadow:      0 -8px 32px rgba(26,39,68,.18);
        z-index:         9999;
        -webkit-overflow-scrolling: touch;
    }
    /* Bottom sheet açıkken summary gizle */
    body.results-open .summary-card {
        display: none !important;
    }
}

/* ============================================================
   MOBILE FORM OVERFLOW FIX
   ============================================================ */
@media (max-width: 991.98px) {
    input[type="date"].form-control { min-width: 0; }
    .d-flex { min-width: 0; }
}

/* ============================================================
   SELECT2 OVERRIDE
   ============================================================ */
.select2-container--classic .select2-selection--single {
    height:        var(--touch-sm);
    border:        1px solid var(--border);
    border-radius: var(--r-sm);
    background:    var(--surface);
    font-family:   var(--font);
    font-size:     15px;
}
.select2-container--classic .select2-selection--single .select2-selection__rendered {
    line-height:   var(--touch-sm);
    padding-left:  14px;
    color:         var(--text);
}
.select2-container--classic .select2-selection--single .select2-selection__arrow {
    height:        calc(var(--touch-sm) - 2px);
    background:    transparent;
    border-left:   1px solid var(--border);
}
.select2-container--classic.select2-container--open .select2-selection--single {
    border-color:  var(--blue);
    box-shadow:    0 0 0 3px rgba(68,114,196,.14);
}
.select2-container--classic .select2-dropdown {
    border:        1px solid var(--blue);
    border-radius: var(--r-sm);
    font-family:   var(--font);
    font-size:     15px;
    box-shadow:    var(--shadow-md);
}
.select2-container--classic .select2-search--dropdown .select2-search__field {
    border:        1px solid var(--border);
    border-radius: var(--r-sm);
    padding:       8px 12px;
    font-family:   var(--font);
    font-size:     14px;
    outline:       none;
    width:         100%;
}
.select2-container--classic .select2-results__option {
    padding:       10px 14px;
    font-size:     14px;
}
.select2-container--classic .select2-results__option--highlighted { background: var(--blue); }

/* ============================================================
   MACHINE RESULT ITEM (auftrag new/edit)
   ============================================================ */
.machine-result-item {
    display:       flex;
    align-items:   center;
    justify-content: space-between;
    padding:       12px 14px;
    cursor:        pointer;
    border-bottom: 1px solid var(--border);
    transition:    background .12s;
    gap:           12px;
}
.machine-result-item:last-child { border-bottom: none; }
.machine-result-item:hover      { background: var(--blue-light); }
.machine-result-item.busy       { opacity: .7; cursor: not-allowed; }
.machine-result-item.busy:hover { background: transparent; }

/* Added item row */
.added-item-row {
    display:       flex;
    align-items:   center;
    gap:           10px;
    padding:       12px 16px;
    border-bottom: 1px solid var(--border);
    background:    var(--surface);
    transition:    background .12s;
}
.added-item-row:last-child { border-bottom: none; }
.added-item-row:hover      { background: var(--surface-2); }

/* ============================================================
   UTILITY
   ============================================================ */
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

.text-blue   { color: var(--blue) !important; }
.text-green  { color: var(--green) !important; }
.text-red    { color: var(--red) !important; }
.text-amber  { color: var(--amber) !important; }

.bg-blue-light { background: var(--blue-light) !important; }

.rounded-full { border-radius: var(--r-full) !important; }

/* Divider */
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--blue-mid); border-radius: 3px; }

/* ============================================================
   RESPONSIVE — MOBILE (< 992px)
   ============================================================ */
@media (max-width: 991.98px) {
    /* Sidebar hidden off-screen */
    #sidebar {
        transform: translateX(-100%);
        width:     280px;
    }
    #sidebar.open { transform: translateX(0); }

    /* Main content full width — kesin sıfırla */
    #main-content {
        margin-left: 0 !important;
        width:       100% !important;
        max-width:   100% !important;
    }

    /* Bottom nav visible */
    #bottom-nav { display: flex; }

    /* FAB visible */
    .fab { display: flex; }

    /* Add bottom margin so content isn't behind bottom nav */
    .page-content {
        padding:       16px;
        margin-bottom: calc(56px + env(safe-area-inset-bottom, 34px) + 16px);
    }

    /* Topbar compact */
    .topbar {
        padding:  0 16px;
        height:   54px;
    }
    .topbar-title { font-size: 16px; }
    .topbar-title small { display: none; }

    /* Tables → scroll */
    .table-responsive { -webkit-overflow-scrolling: touch; }

    /* Hide table on very small screens, show list-cards */
    .mobile-hide   { display: none !important; }
    .mobile-show   { display: block !important; }

    /* Stat cards — 2 per row */
    .stat-grid { grid-template-columns: 1fr 1fr !important; gap: 10px !important; }
    .stat-value { font-size: 22px; }

    /* Forms full width */
    .form-control, .form-select { font-size: 16px; } /* prevents iOS zoom */

    /* Modal bottom sheet style */
    .modal-dialog { margin: 0; align-items: flex-end; min-height: 100%; }
    .modal-content {
        border-radius: var(--r) var(--r) 0 0;
        max-height:    92vh;
        overflow-y:    auto;
    }

    /* Buttons full width in certain contexts */
    .btn-mobile-full { width: 100%; justify-content: center; }

    /* Card padding smaller */
    .card-body { padding: 16px; }
    .card-header { padding: 12px 16px; }
}

/* Very small phones */
@media (max-width: 375px) {
    .stat-value { font-size: 20px; }
    .stat-label { font-size: 10px; }
    .page-content { padding: 12px; }
}

@media (max-width: 991.98px) {
    .stat-card { padding: 14px; }
    .stat-value { font-size: 22px; }
    .stat-icon { width: 40px; height: 40px; }
    .stat-icon .material-symbols-outlined { font-size: 20px; }
}

/* ============================================================
   RESPONSIVE — TABLET (992px–1199px)
   ============================================================ */
@media (min-width: 992px) and (max-width: 1199px) {
    :root { --sidebar-w: 200px; }
    .page-content { padding: 20px 22px; }
}

/* ============================================================
   RESPONSIVE — LARGE DESKTOP (≥ 1400px)
   ============================================================ */
@media (min-width: 1400px) {
    :root { --sidebar-w: 240px; }
    .page-content { padding: 28px 36px; }
}
