:root {
    --ink: #0b1c2c;
    --ink-soft: #16324a;
    --slate: #5b6b7c;
    --mist: #eef3f7;
    --paper: #f7fafc;
    --line: #d7e0e8;
    --surface: #ffffff;
    --surface-muted: #fbfcfe;
    --table-head: #f3f7fa;
    --table-row-border: #eef2f6;
    --table-row-hover: #f7fbfc;
    --amber: #e39b0e;
    --teal: #0f8a7a;
    --teal-soft: #e6f6f3;
    --danger: #c0392b;
    --success: #1f8a4c;
    --warn: #b7791f;
    --shadow: 0 18px 40px rgba(11, 28, 44, .08);
    --topbar-bg: rgba(247, 250, 252, .82);
    --overlay: rgba(0, 0, 0, .4);
    --sidebar: 280px;
    --body-grad-1: rgba(15, 138, 122, .12);
    --body-grad-2: rgba(227, 155, 14, .1);
    --body-base-1: #f4f8fb;
    --body-base-2: #eef3f7;
}

html {
    font-family: "Plus Jakarta Sans", ui-sans-serif, system-ui, sans-serif;
    color: var(--ink);
    background: var(--paper);
}

body {
    min-height: 100vh;
    color: var(--ink);
    background:
        radial-gradient(1200px 500px at 10% -10%, var(--body-grad-1), transparent 55%),
        radial-gradient(900px 420px at 100% 0%, var(--body-grad-2), transparent 50%),
        linear-gradient(180deg, var(--body-base-1) 0%, var(--body-base-2) 100%);
}

h1, h2, h3, .font-display {
    font-family: Outfit, "Plus Jakarta Sans", sans-serif;
    letter-spacing: -0.02em;
}

[x-cloak] { display: none !important; }

.sidebar {
    width: var(--sidebar);
    background: linear-gradient(180deg, #0b1c2c, #16324a);
    box-shadow: 8px 0 30px rgba(11, 28, 44, .18);
    transition: transform .3s ease;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    border-radius: .75rem;
    padding: .625rem .75rem;
    font-size: .875rem;
    font-weight: 500;
    color: rgba(255, 255, 255, .72);
    transition: all .2s ease;
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, .08);
    color: #fff;
    transform: translateX(2px);
}

.sidebar-link.active {
    background: linear-gradient(90deg, rgba(227, 155, 14, .22), rgba(15, 138, 122, .18));
    color: #fff;
    box-shadow: inset 3px 0 0 var(--amber);
}

.brand-logo {
    height: 2.75rem;
    width: 2.75rem;
    border-radius: 1rem;
    object-fit: cover;
    box-shadow: 0 8px 20px rgba(227, 155, 14, .35);
    background: #fff;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(24px);
    background: var(--topbar-bg);
}

.panel {
    border-radius: 1rem;
    border: 1px solid var(--line);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.stat-card {
    position: relative;
    overflow: hidden;
    border-radius: 1rem;
    border: 1px solid var(--line);
    padding: 1.25rem;
    background: var(--surface);
    box-shadow: var(--shadow);
    animation: riseIn .55s ease both;
}

.stat-card:after {
    content: "";
    position: absolute;
    inset: auto -20% -40% auto;
    width: 120px;
    height: 120px;
    border-radius: 999px;
    background: radial-gradient(circle, rgba(15, 138, 122, .14), transparent 70%);
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    border-radius: .75rem;
    padding: .625rem 1rem;
    font-size: .875rem;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, var(--ink-soft), var(--teal));
    box-shadow: 0 10px 22px rgba(15, 138, 122, .25);
    transition: all .2s ease;
}

.btn-primary:hover {
    transform: translateY(-1px);
    filter: brightness(1.05);
}

.btn-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    border-radius: .75rem;
    padding: .625rem 1rem;
    font-size: .875rem;
    font-weight: 600;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink-soft);
    transition: all .2s ease;
}

.btn-ghost:hover {
    background: var(--surface-muted);
}

.field {
    width: 100%;
    border-radius: .75rem;
    border: 1px solid var(--line);
    padding: .625rem .875rem;
    font-size: .875rem;
    background: var(--surface-muted);
    color: var(--ink);
    transition: all .15s ease;
}

.field:focus {
    outline: none;
    border-color: var(--teal);
    background: var(--surface);
    box-shadow: 0 0 0 4px rgba(15, 138, 122, .12);
}

.label {
    margin-bottom: .375rem;
    display: block;
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--slate);
}

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 9999px;
    padding: .25rem .625rem;
    font-size: .75rem;
    font-weight: 600;
}

.badge-pending { background: #fff4db; color: #9a6700; }
.badge-pending_approval { background: #fff4db; color: #9a6700; }
.badge-assigned { background: #e8f0ff; color: #1d4f91; }
.badge-picked_up,
.badge-out_for_delivery { background: #e6f6f3; color: #0f8a7a; }
.badge-delivered { background: #e5f7ec; color: #146c38; }
.badge-cancelled,
.badge-rejected { background: #fde8e6; color: #9b2c2c; }
.badge-returned { background: #f3e8ff; color: #6b21a8; }

.data-table {
    width: 100%;
    text-align: left;
    font-size: .875rem;
    color: var(--ink);
}

.data-table thead th {
    padding: .75rem 1rem;
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--slate);
    background: var(--table-head);
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

.data-table tbody td {
    padding: .875rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--table-row-border);
}

.data-table tbody tr:hover {
    background: var(--table-row-hover);
}

.page-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--ink);
}

@media (min-width: 768px) {
    .page-title { font-size: 1.875rem; }
}

.page-subtitle {
    margin-top: .25rem;
    font-size: .875rem;
    color: var(--slate);
}

.login-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    background: var(--paper);
}

.login-hero {
    position: relative;
    overflow: hidden;
    background:
        linear-gradient(155deg, rgba(11, 28, 44, .92), rgba(15, 138, 122, .78)),
        radial-gradient(800px 400px at 20% 20%, rgba(227, 155, 14, .35), transparent 60%),
        #0b1c2c;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
}

.login-hero:before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, .05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, .05) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: radial-gradient(circle at 30% 40%, black, transparent 75%);
    -webkit-mask-image: radial-gradient(circle at 30% 40%, black, transparent 75%);
    animation: gridDrift 18s linear infinite;
}

.login-card {
    position: relative;
    width: 100%;
    max-width: 28rem;
    border-radius: 1.5rem;
    border: 1px solid var(--line);
    padding: 2rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, .25);
    background: var(--surface);
    animation: riseIn .7s ease both;
}

.alert-success {
    margin-bottom: 1rem;
    border-radius: .75rem;
    border: 1px solid #b7e4c7;
    padding: .75rem 1rem;
    font-size: .875rem;
    background: #e8f8ef;
    color: #146c38;
}

.alert-error {
    margin-bottom: 1rem;
    border-radius: .75rem;
    border: 1px solid #f5c2c0;
    padding: .75rem 1rem;
    font-size: .875rem;
    background: #fdecea;
    color: #9b2c2c;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 1.5rem;
    text-align: center;
    color: var(--slate);
}

@keyframes riseIn {
    0% { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes gridDrift {
    0% { transform: translateY(0); }
    to { transform: translateY(48px); }
}

.animate-rise { animation: riseIn .55s ease both; }

@media (max-width: 1023px) {
    .login-shell { grid-template-columns: 1fr; }
    .login-hero { min-height: 34vh; padding: 2rem; }
}

@media (min-width: 1024px) {
    .main-shell { padding-left: var(--sidebar); }
}

/* Pagination */
.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    list-style: none;
    padding: 0;
    margin: 0;
}

.pagination > li > a,
.pagination > li > span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.25rem;
    height: 2.25rem;
    padding: 0 .65rem;
    border-radius: .65rem;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink-soft);
    font-size: .85rem;
    font-weight: 600;
}

.pagination > .active > span {
    background: linear-gradient(135deg, var(--ink-soft), var(--teal));
    border-color: transparent;
    color: #fff;
}

.pagination > .disabled > span {
    opacity: .45;
}

/* Searchable select (Bilal-style) */
.search-select { position: relative; }
.search-select__control {
    position: relative;
    display: flex;
    align-items: center;
    border-radius: 1rem;
    border: 1px solid var(--line);
    min-height: 3rem;
    background: linear-gradient(180deg, var(--surface) 0%, var(--surface-muted) 100%);
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
    transition: all .15s ease;
}
.search-select.is-open .search-select__control,
.search-select__control:focus-within {
    border-color: var(--teal);
    background: var(--surface);
    box-shadow: 0 0 0 4px rgba(15, 138, 122, .12), 0 8px 24px rgba(15, 23, 42, .06);
}
.search-select__icon {
    pointer-events: none;
    position: absolute;
    left: .875rem;
    display: flex;
    height: 1.25rem;
    width: 1.25rem;
    color: var(--slate);
}
.search-select__icon svg,
.search-select__actions svg,
.search-select__check svg { width: 1rem; height: 1rem; }
.search-select__input {
    width: 100%;
    border: 0;
    background: transparent;
    padding: .75rem 4rem .75rem 2.75rem;
    font-size: .875rem;
    outline: none;
    color: var(--ink);
}
.search-select__input::placeholder { color: var(--slate); opacity: .9; }
.search-select__actions {
    position: absolute;
    top: 0;
    bottom: 0;
    right: .5rem;
    display: flex;
    align-items: center;
    gap: .125rem;
}
.search-select__clear {
    display: inline-flex;
    height: 1.75rem;
    width: 1.75rem;
    align-items: center;
    justify-content: center;
    border-radius: .5rem;
    color: var(--slate);
}
.search-select__clear:hover { background: var(--surface-muted); color: var(--ink); }
.search-select__chevron {
    display: inline-flex;
    height: 1.75rem;
    width: 1.75rem;
    align-items: center;
    justify-content: center;
    color: var(--slate);
    transition: transform .2s ease;
}
.search-select__chevron.rotate { transform: rotate(180deg); color: var(--teal); }
.search-select__menu {
    position: absolute;
    z-index: 50;
    margin-top: .5rem;
    max-height: 18rem;
    width: 100%;
    overflow: auto;
    border-radius: 1rem;
    border: 1px solid var(--line);
    padding: .375rem 0;
    background: var(--surface);
    box-shadow: 0 18px 40px rgba(15, 23, 42, .14), 0 2px 8px rgba(15, 23, 42, .06);
}
.search-select__option {
    display: flex;
    width: 100%;
    align-items: center;
    gap: .75rem;
    padding: .625rem .75rem;
    text-align: left;
    color: var(--ink);
    transition: background .15s ease;
}
.search-select__option:hover,
.search-select__option.is-highlight { background: var(--teal-soft); }
.search-select__option.is-active { background: color-mix(in srgb, var(--teal-soft) 80%, transparent); }
.search-select__avatar {
    display: flex;
    height: 2.25rem;
    width: 2.25rem;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    border-radius: .75rem;
    font-size: .75rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--teal), #0b7a6c);
    color: #fff;
}
.search-select__body { min-width: 0; flex: 1; }
.search-select__name {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: .875rem;
    font-weight: 600;
}
.search-select__sub {
    margin-top: .125rem;
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    font-size: .75rem;
    color: var(--slate);
}
.search-select__code {
    display: inline-flex;
    border-radius: .375rem;
    padding: .125rem .375rem;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    background: var(--surface-muted);
    border: 1px solid var(--line);
}
.search-select__meta {
    flex-shrink: 0;
    border-radius: .5rem;
    padding: .25rem .5rem;
    font-size: 11px;
    font-weight: 600;
    background: var(--surface-muted);
    color: var(--teal);
    border: 1px solid var(--line);
}
.search-select__empty {
    padding: 1.5rem 1rem;
    text-align: center;
    font-size: .875rem;
    color: var(--slate);
}
