/* ============================================================
   Canon Copier Sales & Service Center
   Theme: Canon Red / White / Dark Gray / Light Gray
   ============================================================ */

/* ---------- Design tokens ---------- */
:root {
  color-scheme: light;
  --canon-red: #CC0000;
  --canon-red-dark: #A30000;
  --canon-red-soft: #ffe5e5;
  --white: #FFFFFF;
  --dark-gray: #333333;
  --light-gray: #F5F5F5;

  --bg: #F5F5F5;
  --surface: #FFFFFF;
  --surface-2: #fafafa;
  --text: #333333;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.12);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 250px;

  --green: #16a34a;
  --amber: #d97706;
  --blue: #2563eb;
  --red: #dc2626;

  --font: "Segoe UI", Roboto, "Helvetica Neue", Arial, system-ui, sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #16181c;
  --surface: #1f2228;
  --surface-2: #262a31;
  --text: #e5e7eb;
  --text-muted: #9ca3af;
  --border: #333941;
  --light-gray: #262a31;
  --shadow: 0 1px 3px rgba(0,0,0,.4);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.5);
  --canon-red-soft: #3a1a1a;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--canon-red); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3,h4 { margin: 0 0 .5rem; font-weight: 700; line-height: 1.25; }
img { max-width: 100%; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: .55rem .95rem; font-size: .9rem; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: all .15s ease; white-space: nowrap; background: none;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--canon-red); color: #fff; }
.btn-primary:hover { background: var(--canon-red-dark); }
.btn-outline { border-color: var(--border); color: var(--text); background: var(--surface); }
.btn-outline:hover { border-color: var(--canon-red); color: var(--canon-red); }
.btn-ghost { color: var(--text-muted); }
.btn-ghost:hover { color: var(--canon-red); background: var(--canon-red-soft); }
.btn-success { background: var(--green); color:#fff; }
.btn-danger { background: var(--red); color:#fff; }
.btn-wa { background:#25D366; color:#fff; }
.btn-wa:hover { background:#1da851; }
.btn-sm { padding: .35rem .6rem; font-size: .8rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity:.5; cursor:not-allowed; transform:none; }

/* ---------- Forms ---------- */
.field { margin-bottom: 1rem; }
.field label { display:block; font-size:.82rem; font-weight:600; margin-bottom:.35rem; color: var(--text); }
.field .req { color: var(--canon-red); }
input, select, textarea {
  width: 100%; padding: .6rem .7rem; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
  font-family: inherit; font-size: .9rem; transition: border .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--canon-red);
  box-shadow: 0 0 0 3px var(--canon-red-soft);
}
textarea { resize: vertical; min-height: 80px; }
.form-grid { display:grid; grid-template-columns: repeat(2, 1fr); gap: 0 1rem; }
.form-grid .full { grid-column: 1 / -1; }
.hint { font-size:.78rem; color: var(--text-muted); margin-top:.3rem; }

/* ---------- Auth screens ---------- */
.auth-wrap {
  min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr;
}
.auth-hero {
  background: linear-gradient(135deg, var(--canon-red) 0%, var(--canon-red-dark) 100%);
  color: #fff; padding: 3rem; display:flex; flex-direction:column; justify-content:center;
}
.auth-hero .brand { display:flex; align-items:center; gap:.7rem; margin-bottom:2rem; }
.auth-hero h1 { font-size: 2.1rem; }
.auth-hero p { opacity:.92; max-width: 420px; }
.auth-hero .feat { margin-top:2rem; display:flex; flex-direction:column; gap:.8rem; }
.auth-hero .feat div { display:flex; align-items:center; gap:.6rem; opacity:.95; }
.auth-panel {
  display:flex; align-items:center; justify-content:center; padding: 2rem; background: var(--bg);
}
.auth-card {
  width: 100%; max-width: 420px; background: var(--surface);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 2rem;
  border: 1px solid var(--border);
}
.auth-card h2 { font-size:1.5rem; }
.auth-tabs { display:flex; gap:.4rem; background: var(--light-gray); padding:.3rem; border-radius: var(--radius-sm); margin-bottom:1.4rem; }
.auth-tabs button { flex:1; padding:.5rem; border:none; background:none; border-radius:6px; font-weight:600; cursor:pointer; color: var(--text-muted); font-family:inherit; }
.auth-tabs button.active { background: var(--surface); color: var(--canon-red); box-shadow: var(--shadow); }
.role-pick { display:flex; gap:.6rem; margin-bottom:1.2rem; }
.role-pick label {
  flex:1; border:1.5px solid var(--border); border-radius: var(--radius-sm); padding:.7rem; text-align:center;
  cursor:pointer; font-weight:600; font-size:.85rem; transition: all .15s;
}
.role-pick input { display:none; }
.role-pick input:checked + span { color: var(--canon-red); }
.role-pick label:has(input:checked) { border-color: var(--canon-red); background: var(--canon-red-soft); }
.demo-note { margin-top:1rem; font-size:.78rem; color: var(--text-muted); background: var(--light-gray); padding:.7rem; border-radius: var(--radius-sm); }

/* ---------- Brand logo ---------- */
.logo {
  display:inline-flex; align-items:center; gap:.55rem; font-weight:800; letter-spacing:-.02em;
}
.logo .mark {
  background: var(--canon-red); color:#fff; font-weight:800; width: 34px; height:34px;
  border-radius:8px; display:grid; place-items:center; font-size:1.1rem;
}
.logo .mark.sm { width:28px; height:28px; font-size:.95rem; }
.logo-txt small { display:block; font-size:.62rem; font-weight:600; color: var(--text-muted); letter-spacing:.06em; text-transform:uppercase; }

/* ---------- App shell ---------- */
.shell { display:flex; min-height:100vh; }
.sidebar {
  width: var(--sidebar-w); background: var(--surface); border-right:1px solid var(--border);
  display:flex; flex-direction:column; position:fixed; inset:0 auto 0 0; z-index:40;
  transition: transform .25s ease;
}
.sidebar .side-head { padding: 1.1rem 1.1rem; border-bottom:1px solid var(--border); display:flex; align-items:center; justify-content:space-between; }
.sidebar nav { flex:1; overflow-y:auto; padding:.7rem; }
.nav-group-label { font-size:.68rem; text-transform:uppercase; letter-spacing:.08em; color: var(--text-muted); padding:.9rem .7rem .3rem; font-weight:700; }
.nav-item {
  display:flex; align-items:center; gap:.7rem; padding:.6rem .7rem; border-radius: var(--radius-sm);
  color: var(--text); cursor:pointer; font-weight:600; font-size:.88rem; margin-bottom:.15rem;
}
.nav-item:hover { background: var(--light-gray); text-decoration:none; }
.nav-item.active { background: var(--canon-red); color:#fff; }
.nav-item .ico { width:20px; text-align:center; flex-shrink:0; }
.nav-item .badge { margin-left:auto; }
.side-foot { padding:.8rem; border-top:1px solid var(--border); }

.main { flex:1; margin-left: var(--sidebar-w); display:flex; flex-direction:column; min-width:0; }
.topbar {
  height:60px; background: var(--surface); border-bottom:1px solid var(--border);
  display:flex; align-items:center; gap:1rem; padding:0 1.2rem; position:sticky; top:0; z-index:30;
}
.topbar .menu-btn { display:none; }
.topbar .page-title { font-size:1.1rem; font-weight:700; }
.topbar .spacer { flex:1; }
.search-box { position:relative; max-width:340px; flex:1; }
.search-box input { padding-left:2.1rem; }
.search-box .ico { position:absolute; left:.7rem; top:50%; transform:translateY(-50%); color:var(--text-muted); }
.search-results {
  position:absolute; top:110%; left:0; right:0; background:var(--surface); border:1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); max-height:360px; overflow-y:auto; z-index:60;
}
.search-results .sr-item { padding:.6rem .8rem; cursor:pointer; border-bottom:1px solid var(--border); display:flex; gap:.6rem; align-items:center; }
.search-results .sr-item:hover { background: var(--light-gray); }
.search-results .sr-type { font-size:.66rem; text-transform:uppercase; background: var(--canon-red-soft); color:var(--canon-red); padding:.1rem .4rem; border-radius:4px; font-weight:700; }
.icon-btn { width:38px; height:38px; border-radius:8px; border:1px solid var(--border); background:var(--surface); cursor:pointer; display:grid; place-items:center; color:var(--text); }
.icon-btn:hover { border-color: var(--canon-red); color:var(--canon-red); }
.content { padding: 1.4rem; flex:1; }

/* user chip */
.user-chip { display:flex; align-items:center; gap:.55rem; cursor:pointer; padding:.25rem .3rem; border-radius:8px; }
.user-chip:hover { background: var(--light-gray); }
.avatar { width:34px; height:34px; border-radius:50%; background: var(--canon-red); color:#fff; display:grid; place-items:center; font-weight:700; font-size:.85rem; }
.user-chip .u-name { font-weight:600; font-size:.85rem; }
.user-chip .u-role { font-size:.7rem; color:var(--text-muted); }

/* ---------- Cards / dashboard ---------- */
.page-head { display:flex; align-items:flex-start; justify-content:space-between; gap:1rem; margin-bottom:1.2rem; flex-wrap:wrap; }
.page-head h1 { font-size:1.4rem; }
.page-head p { color:var(--text-muted); margin:0; }

.stat-grid { display:grid; grid-template-columns: repeat(auto-fill, minmax(210px,1fr)); gap:1rem; margin-bottom:1.4rem; }
.stat-card {
  background: var(--surface); border:1px solid var(--border); border-radius: var(--radius);
  padding:1.1rem; box-shadow: var(--shadow); position:relative; overflow:hidden;
}
.stat-card .s-ico { width:44px; height:44px; border-radius:10px; display:grid; place-items:center; font-size:1.2rem; margin-bottom:.7rem; }
.stat-card .s-val { font-size:1.8rem; font-weight:800; line-height:1; }
.stat-card .s-label { color:var(--text-muted); font-size:.82rem; margin-top:.3rem; }
.stat-card .s-sub { font-size:.72rem; margin-top:.4rem; font-weight:600; }

.card {
  background: var(--surface); border:1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom:1.2rem;
}
.card-head { padding:1rem 1.1rem; border-bottom:1px solid var(--border); display:flex; align-items:center; justify-content:space-between; gap:.6rem; flex-wrap:wrap; }
.card-head h3 { margin:0; font-size:1.02rem; }
.card-body { padding:1.1rem; }
.card-grid { display:grid; gap:1.2rem; }
.grid-2 { grid-template-columns: repeat(2,1fr); }
.grid-3 { grid-template-columns: repeat(3,1fr); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x:auto; }
table.data { width:100%; border-collapse:collapse; font-size:.86rem; }
table.data th, table.data td { text-align:left; padding:.7rem .8rem; border-bottom:1px solid var(--border); white-space:nowrap; }
table.data th { font-size:.72rem; text-transform:uppercase; letter-spacing:.04em; color:var(--text-muted); font-weight:700; background: var(--surface-2); position:sticky; top:0; }
table.data tbody tr:hover { background: var(--light-gray); }
table.data td .row-actions { display:flex; gap:.35rem; }
.table-toolbar { display:flex; gap:.6rem; align-items:center; flex-wrap:wrap; margin-bottom:.9rem; }
.table-toolbar .grow { flex:1; min-width:180px; }

/* ---------- Badges / status ---------- */
.badge { display:inline-flex; align-items:center; gap:.3rem; font-size:.72rem; font-weight:700; padding:.22rem .55rem; border-radius:100px; }
.badge-green { background: #dcfce7; color:#166534; }
.badge-amber { background: #fef3c7; color:#92400e; }
.badge-red { background: #fee2e2; color:#991b1b; }
.badge-blue { background: #dbeafe; color:#1e40af; }
.badge-gray { background: var(--light-gray); color:var(--text-muted); }
[data-theme="dark"] .badge-green{background:#14351f;color:#4ade80}
[data-theme="dark"] .badge-amber{background:#3a2c0a;color:#fbbf24}
[data-theme="dark"] .badge-red{background:#3a1414;color:#f87171}
[data-theme="dark"] .badge-blue{background:#132347;color:#93c5fd}
.dot { width:8px; height:8px; border-radius:50%; display:inline-block; }

/* priority pills */
.pri-Low{background:#dcfce7;color:#166534}
.pri-Medium{background:#dbeafe;color:#1e40af}
.pri-High{background:#fef3c7;color:#92400e}
.pri-Emergency{background:#fee2e2;color:#991b1b}

/* ---------- Timeline ---------- */
.timeline { position:relative; padding-left:1.6rem; }
.timeline::before { content:''; position:absolute; left:7px; top:4px; bottom:4px; width:2px; background: var(--border); }
.tl-step { position:relative; padding:0 0 1.3rem; }
.tl-step .tl-dot { position:absolute; left:-1.6rem; top:2px; width:16px; height:16px; border-radius:50%; background: var(--surface); border:2px solid var(--border); }
.tl-step.done .tl-dot { background: var(--green); border-color: var(--green); }
.tl-step.current .tl-dot { background: var(--canon-red); border-color: var(--canon-red); box-shadow:0 0 0 4px var(--canon-red-soft); }
.tl-step .tl-title { font-weight:700; font-size:.9rem; }
.tl-step .tl-time { font-size:.75rem; color:var(--text-muted); }
.tl-step.pending .tl-title { color: var(--text-muted); }

/* ---------- Modal ---------- */
.modal-overlay {
  position:fixed; inset:0; background:rgba(0,0,0,.5); display:flex; align-items:flex-start; justify-content:center;
  padding:2rem 1rem; z-index:100; overflow-y:auto; animation: fade .15s ease;
}
.modal {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  width:100%; max-width:640px; margin:auto; animation: pop .18s ease; border:1px solid var(--border);
}
.modal.lg { max-width: 860px; }
.modal.sm { max-width: 420px; }
.modal-head { padding:1rem 1.2rem; border-bottom:1px solid var(--border); display:flex; align-items:center; justify-content:space-between; }
.modal-head h3 { margin:0; font-size:1.1rem; }
.modal-body { padding:1.2rem; max-height:70vh; overflow-y:auto; }
.modal-foot { padding:.9rem 1.2rem; border-top:1px solid var(--border); display:flex; justify-content:flex-end; gap:.6rem; }
.modal .close { background:none; border:none; font-size:1.4rem; cursor:pointer; color:var(--text-muted); line-height:1; }

@keyframes fade { from{opacity:0} to{opacity:1} }
@keyframes pop { from{opacity:0; transform:translateY(10px) scale(.98)} to{opacity:1; transform:none} }

/* ---------- Toast ---------- */
.toast-container { position:fixed; top:1rem; right:1rem; z-index:200; display:flex; flex-direction:column; gap:.6rem; max-width: 360px; }
.toast {
  background: var(--surface); border:1px solid var(--border); border-left:4px solid var(--canon-red);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding:.8rem 1rem; display:flex; gap:.7rem; align-items:flex-start;
  animation: slidein .25s ease;
}
.toast.success { border-left-color: var(--green); }
.toast.error { border-left-color: var(--red); }
.toast.info { border-left-color: var(--blue); }
.toast .t-ico { font-size:1.1rem; }
.toast .t-title { font-weight:700; font-size:.88rem; }
.toast .t-msg { font-size:.8rem; color:var(--text-muted); }
@keyframes slidein { from{opacity:0; transform:translateX(40px)} to{opacity:1; transform:none} }

/* ---------- Loading ---------- */
.spinner { width:38px; height:38px; border:3px solid var(--border); border-top-color: var(--canon-red); border-radius:50%; animation: spin .7s linear infinite; }
.loading-wrap { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:1rem; padding:4rem; color:var(--text-muted); }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--light-gray) 25%, var(--surface-2) 50%, var(--light-gray) 75%); background-size:200% 100%; animation: shimmer 1.2s infinite; border-radius:6px; }
@keyframes shimmer { to { background-position:-200% 0; } }

/* ---------- Pagination ---------- */
.pagination { display:flex; gap:.3rem; align-items:center; justify-content:flex-end; margin-top:1rem; flex-wrap:wrap; }
.pagination button { min-width:34px; height:34px; border:1px solid var(--border); background:var(--surface); border-radius:6px; cursor:pointer; color:var(--text); font-weight:600; }
.pagination button.active { background:var(--canon-red); color:#fff; border-color:var(--canon-red); }
.pagination button[disabled] { opacity:.4; cursor:not-allowed; }
.pagination .info { color:var(--text-muted); font-size:.8rem; margin-right:auto; }

/* ---------- Charts (SVG/CSS) ---------- */
.chart-bars { display:flex; align-items:flex-end; gap:.5rem; height:180px; padding-top:.5rem; }
.chart-bars .bar-col { flex:1; display:flex; flex-direction:column; align-items:center; gap:.4rem; height:100%; justify-content:flex-end; }
.chart-bars .bar { width:70%; max-width:34px; background:linear-gradient(180deg,var(--canon-red),var(--canon-red-dark)); border-radius:6px 6px 0 0; transition:height .6s ease; position:relative; }
.chart-bars .bar:hover::after { content:attr(data-val); position:absolute; top:-1.4rem; left:50%; transform:translateX(-50%); background:var(--dark-gray); color:#fff; font-size:.7rem; padding:.1rem .4rem; border-radius:4px; white-space:nowrap; }
.chart-bars .bar-lbl { font-size:.68rem; color:var(--text-muted); text-align:center; }
.legend { display:flex; flex-wrap:wrap; gap:.8rem; margin-top:.8rem; font-size:.78rem; }
.legend span { display:inline-flex; align-items:center; gap:.35rem; }
.donut-wrap { display:flex; align-items:center; gap:1.4rem; flex-wrap:wrap; }

.hbar { display:flex; flex-direction:column; gap:.7rem; }
.hbar .row { display:grid; grid-template-columns:120px 1fr 40px; align-items:center; gap:.6rem; font-size:.82rem; }
.hbar .track { background:var(--light-gray); border-radius:100px; height:12px; overflow:hidden; }
.hbar .fill { height:100%; background:linear-gradient(90deg,var(--canon-red),var(--canon-red-dark)); border-radius:100px; transition:width .6s ease; }

/* ---------- Misc ---------- */
.empty { text-align:center; padding:3rem 1rem; color:var(--text-muted); }
.empty .e-ico { font-size:2.5rem; margin-bottom:.5rem; opacity:.5; }
.muted { color:var(--text-muted); }
.text-red { color:var(--canon-red); }
.text-green { color:var(--green); }
.right { text-align:right; }
.mono { font-family: ui-monospace, "Courier New", monospace; }
.tag-list { display:flex; flex-wrap:wrap; gap:.4rem; }
.kv { display:grid; grid-template-columns: 150px 1fr; gap:.4rem 1rem; font-size:.88rem; }
.kv dt { color:var(--text-muted); font-weight:600; }
.kv dd { margin:0; font-weight:600; }
.divider { height:1px; background:var(--border); margin:1rem 0; }
.flex { display:flex; align-items:center; gap:.6rem; }
.flex-between { display:flex; align-items:center; justify-content:space-between; gap:.6rem; }
.gap-sm { gap:.4rem; }
.wrap { flex-wrap:wrap; }
.mt { margin-top:1rem; } .mb { margin-bottom:1rem; }
.progress-ring { transform: rotate(-90deg); }

/* Copier / model cards */
.model-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(240px,1fr)); gap:1rem; }
.model-card { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); overflow:hidden; box-shadow:var(--shadow); }
.model-card .m-img { height:150px; background:var(--light-gray); display:grid; place-items:center; color:var(--text-muted); font-size:2.5rem; }
.model-card .m-body { padding:1rem; }
.model-card .m-body h4 { margin:0 0 .2rem; }
.copier-card { border:1px solid var(--border); border-radius:var(--radius); padding:1rem; background:var(--surface-2); }
.copier-card .c-top { display:flex; justify-content:space-between; align-items:flex-start; gap:.5rem; }

/* Invoice print */
.invoice { background:#fff; color:#222; font-size:13px; }
.invoice .inv-head { display:flex; justify-content:space-between; border-bottom:3px solid var(--canon-red); padding-bottom:1rem; margin-bottom:1.2rem; }
.invoice table { width:100%; border-collapse:collapse; margin:1rem 0; }
.invoice table th { background:var(--canon-red); color:#fff; padding:.5rem; text-align:left; font-size:12px; }
.invoice table td { padding:.5rem; border-bottom:1px solid #eee; }
.invoice .totals { width:280px; margin-left:auto; }
.invoice .totals .grand { font-size:1.15rem; font-weight:800; color:var(--canon-red); border-top:2px solid var(--canon-red); }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .grid-2, .grid-3 { grid-template-columns:1fr; }
}
@media (max-width: 860px) {
  .auth-wrap { grid-template-columns:1fr; }
  .auth-hero { display:none; }
  .form-grid { grid-template-columns:1fr; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left:0; }
  .topbar .menu-btn { display:grid; }
  .search-box { display:none; }
  .topbar.search-open .search-box { display:block; position:absolute; left:1rem; right:1rem; top:70px; background:var(--surface); z-index:50; max-width:none; }
  .backdrop { position:fixed; inset:0; background:rgba(0,0,0,.4); z-index:39; }
  .kv { grid-template-columns:1fr; }
  .kv dt { margin-top:.4rem; }
}
@media print {
  .no-print { display:none !important; }
  body { background:#fff; }
  .modal-overlay { position:static; background:none; padding:0; }
  .modal { box-shadow:none; max-width:none; border:none; }
  .modal-body { max-height:none; overflow:visible; }
}
