/* =====================================================================
   KGESMS — KETWA Global Shop Management System — Stylesheet
   ===================================================================== */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f1f5f9;
    color: #1e293b;
    font-size: 14px;
}
a { color: #059669; text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout */
.layout { display: flex; min-height: 100vh; }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.content { padding: 22px 26px 60px; max-width: 1500px; width: 100%; }

/* Sidebar */
.sidebar {
    width: 248px; flex-shrink: 0;
    background: #0f172a; color: #cbd5e1;
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 18px 18px 14px; border-bottom: 1px solid #1e293b; }
.brand-logo {
    width: 40px; height: 40px; border-radius: 10px; background: linear-gradient(135deg, #059669, #34d399);
    color: #fff; font-weight: 800; font-size: 20px; display: flex; align-items: center; justify-content: center;
    object-fit: cover;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { color: #f8fafc; font-size: 14px; }
.brand-text small { color: #94a3b8; font-size: 11px; }

.nav { padding: 12px 10px; flex: 1; }
.nav-item, .nav-group summary {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border-radius: 8px; color: #cbd5e1; font-weight: 500; cursor: pointer;
}
.nav-item:hover, .nav-group summary:hover { background: #1e293b; color: #fff; text-decoration: none; }
.nav-icon { width: 22px; text-align: center; }
.nav-group { margin-top: 2px; }
.nav-group summary { list-style: none; }
.nav-group summary::-webkit-details-marker { display: none; }
.nav-group[open] summary { background: #1e293b; color: #fff; }
.nav-sub {
    display: block; padding: 7px 12px 7px 44px; border-radius: 8px; color: #94a3b8; font-size: 13px;
}
.nav-sub:hover { background: #1e293b; color: #fff; text-decoration: none; }
.sidebar-foot { padding: 14px 18px; border-top: 1px solid #1e293b; color: #64748b; }

/* Topbar */
.topbar {
    display: flex; align-items: center; gap: 14px;
    background: #fff; padding: 12px 26px; border-bottom: 1px solid #e2e8f0;
    position: sticky; top: 0; z-index: 50;
}
.page-title { font-size: 18px; margin: 0; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.chip { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; border-radius: 999px; padding: 4px 12px; font-size: 12px; font-weight: 600; }
.user-menu { display: flex; align-items: center; gap: 8px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: #059669; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.u-name { font-weight: 600; }
.u-role { color: #64748b; font-size: 12px; }
.menu-toggle { display: none; background: none; border: 0; font-size: 20px; cursor: pointer; }

/* Cards */
.card { background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 18px; margin-bottom: 20px; box-shadow: 0 1px 2px rgba(15,23,42,.04); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-header h3 { margin: 0; font-size: 15px; }

/* Stat cards */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card {
    background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 16px;
    display: flex; align-items: center; gap: 14px;
}
.stat-icon { width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 22px; }
.stat-icon.primary { background: #ecfdf5; color: #059669; }
.stat-icon.info    { background: #eff6ff; color: #2563eb; }
.stat-icon.success { background: #ecfdf5; color: #059669; }
.stat-icon.warning { background: #fffbeb; color: #d97706; }
.stat-icon.danger  { background: #fef2f2; color: #dc2626; }
.stat-icon.secondary { background: #f1f5f9; color: #475569; }
.stat-content .stat-value { font-size: 22px; font-weight: 800; line-height: 1.1; }
.stat-content .stat-label { color: #64748b; font-size: 12px; }

/* Grid helpers */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 1100px) { .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* Tables */
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid #e2e8f0; vertical-align: middle; }
th { background: #f8fafc; color: #475569; font-weight: 600; white-space: nowrap; }
tbody tr:hover { background: #f8fafc; }
.td-actions { white-space: nowrap; text-align: right; }
.td-actions a { margin-left: 4px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: #64748b; }
small { font-size: 12px; }

/* Badges */
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-info    { background: #dbeafe; color: #1e40af; }
.badge-secondary { background: #e2e8f0; color: #334155; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px; border-radius: 8px; border: 1px solid transparent;
    font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary   { background: #059669; color: #fff; }
.btn-primary:hover { background: #047857; }
.btn-outline-primary { background: #fff; color: #059669; border-color: #059669; }
.btn-outline-primary:hover { background: #ecfdf5; }
.btn-danger    { background: #dc2626; color: #fff; }
.btn-outline-danger { background: #fff; color: #dc2626; border-color: #dc2626; }
.btn-outline-danger:hover { background: #fef2f2; }
.btn-secondary { background: #f1f5f9; color: #334155; border-color: #e2e8f0; }
.btn-warning   { background: #d97706; color: #fff; }
.btn-info      { background: #2563eb; color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 12px 20px; font-size: 15px; }
.btn-block { width: 100%; justify-content: center; }

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; font-weight: 700; color: #475569; margin-bottom: 5px; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 9px 11px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 14px; background: #fff;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: 2px solid #a7f3d0; border-color: #059669;
}
.form-group textarea { min-height: 70px; resize: vertical; }
.form-group .hint { font-size: 11px; color: #94a3b8; }
.form-check { display: flex; gap: 8px; align-items: center; font-size: 13px; }

/* Alerts */
.alert { padding: 11px 14px; border-radius: 10px; margin-bottom: 16px; font-size: 14px; }
.alert-success { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.alert-danger  { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.alert-info    { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* Toolbar */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.toolbar input[type=text], .toolbar select {
    padding: 8px 11px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 13px;
}

/* Page header */
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 19px; }
.page-head .spacer { flex: 1; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid #e2e8f0; margin-bottom: 18px; flex-wrap: wrap; }
.tab { padding: 9px 16px; border-radius: 8px 8px 0 0; color: #64748b; font-weight: 600; }
.tab.active { background: #fff; color: #059669; border: 1px solid #e2e8f0; border-bottom: 2px solid #059669; }
.tab:hover { text-decoration: none; color: #059669; }

/* POS */
.pos-layout { display: grid; grid-template-columns: 1fr 380px; gap: 18px; }
.pos-products { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.pos-tile {
    background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; padding: 12px; cursor: pointer; text-align: center;
}
.pos-tile:hover { border-color: #059669; box-shadow: 0 3px 10px rgba(5,150,105,.15); }
.pos-tile .name { font-size: 12px; font-weight: 600; min-height: 30px; }
.pos-tile .price { color: #059669; font-weight: 800; }
.pos-tile .stock { font-size: 11px; color: #64748b; }
.pos-cart { background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 16px; position: sticky; top: 76px; max-height: calc(100vh - 100px); overflow: auto; }
.cart-total { display: flex; justify-content: space-between; font-size: 17px; font-weight: 800; padding: 12px 0; border-top: 2px solid #e2e8f0; margin-top: 10px; }
@media (max-width: 960px) { .pos-layout { grid-template-columns: 1fr 340px; gap: 16px; } }
@media (max-width: 768px) { .pos-layout { grid-template-columns: 1fr 300px; gap: 14px; } }
@media (max-width: 560px) { .pos-layout { grid-template-columns: 1fr 260px; gap: 12px; } }

/* Modal */
.modal-backdrop { display: none; position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 200; align-items: center; justify-content: center; }
.modal-backdrop.show { display: flex; }
.modal { background: #fff; border-radius: 14px; padding: 22px; width: 480px; max-width: 94vw; max-height: 90vh; overflow: auto; }

/* Receipt */
.receipt { font-family: 'Courier New', monospace; font-size: 12px; max-width: 300px; margin: 0 auto; }
.receipt h3 { text-align: center; margin: 4px 0; }
.receipt table { width: 100%; }
.receipt .total-row td { border-top: 1px dashed #94a3b8; font-weight: 700; }

/* Misc */
.kpi { font-size: 28px; font-weight: 800; color: #059669; }
.progress { height: 8px; background: #e2e8f0; border-radius: 999px; overflow: hidden; margin-top: 5px; }
.progress > div { height: 100%; background: #059669; }
.pos-tile.low { border-color: #f59e0b; }
.print-only { display: none; }
@media print {
    .sidebar, .topbar, .toolbar, .btn, .no-print { display: none !important; }
    .layout { display: block; }
    .content { padding: 0; }
    .print-only { display: block; }
    body { background: #fff; }
}

/* Modern additions */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi-card {
    background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 16px;
    display: flex; align-items: center; gap: 14px;
    box-shadow: 0 1px 2px rgba(15,23,42,.04);
}
.kpi-icon { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 20px; }
.kpi-icon.green { background: #ecfdf5; color: #059669; }
.kpi-icon.red { background: #fef2f2; color: #dc2626; }
.kpi-icon.blue { background: #eff6ff; color: #2563eb; }
.kpi-value { font-size: 20px; font-weight: 800; line-height: 1.1; }
.kpi-label { color: #64748b; font-size: 12px; }

.section-title { font-size: 15px; font-weight: 700; color: #0f172a; margin: 0 0 14px; }

.filter-bar {
    background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 14px 16px;
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 20px;
    box-shadow: 0 1px 2px rgba(15,23,42,.04);
}
.filter-bar input, .filter-bar select {
    padding: 8px 11px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 13px; background: #fff;
}
.filter-bar .spacer { flex: 1; }

.text-center { text-align: center; }