/* =====================================================================
   Arabian Roadlines - Waybill System
   Brand palette pulled directly from the logo.
   ===================================================================== */

:root {
  --crimson:        #A6192E;   /* deep brand red (logo text) */
  --crimson-700:    #8A0F22;
  --crimson-300:    #D9355A;
  --red-bright:     #D62828;   /* truck body */
  --steel:          #8C8C8C;   /* the road */
  --steel-200:      #E6E6E6;
  --steel-50:       #F5F5F6;
  --ink:            #1A1A1A;
  --ink-soft:       #2D2D2D;
  --paper:          #FCFCFA;
  --globe-blue:     #1F4E8C;   /* accent only */

  --ok:             #1F7A4D;
  --warn:           #B47200;
  --danger:         #B91C1C;

  --radius:         10px;
  --radius-sm:      6px;
  --shadow-sm:      0 1px 2px rgba(26,26,26,0.06), 0 1px 3px rgba(26,26,26,0.04);
  --shadow-md:      0 4px 12px rgba(26,26,26,0.08), 0 2px 4px rgba(26,26,26,0.04);
  --shadow-lg:      0 20px 40px -12px rgba(26,26,26,0.15);

  --font-sans:      "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-serif:     "DM Serif Display", Georgia, "Times New Roman", serif;
  --font-mono:      "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--paper);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--crimson); text-decoration: none; }
a:hover { color: var(--crimson-700); }

h1, h2, h3, h4 { font-family: var(--font-serif); font-weight: 400; letter-spacing: -0.01em; color: var(--ink); margin: 0 0 .5em; }
h1 { font-size: 2.1rem; line-height: 1.15; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; font-family: var(--font-sans); font-weight: 700; letter-spacing: .01em; text-transform: uppercase; color: var(--ink-soft); }

hr { border: none; border-top: 1px solid var(--steel-200); margin: 1.5rem 0; }

/* ====== Layout ====== */
.app { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }

.sidebar {
  background: linear-gradient(180deg, var(--ink) 0%, #111 100%);
  color: #ECECEC;
  padding: 1.25rem 1rem;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  border-right: 1px solid #0a0a0a;
}
.sidebar__brand {
  display: flex; align-items: center; gap: .75rem;
  padding: .25rem .25rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  margin-bottom: 1rem;
}
.sidebar__brand img { width: 44px; height: 44px; object-fit: contain; background: #fff; border-radius: 8px; padding: 4px; }
.sidebar__brand strong { display: block; font-size: .95rem; letter-spacing: .01em; }
.sidebar__brand span { font-size: .72rem; color: var(--steel); text-transform: uppercase; letter-spacing: .12em; }

.sidebar__nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar__nav a {
  display: flex; align-items: center; gap: .7rem;
  padding: .65rem .85rem;
  border-radius: var(--radius-sm);
  color: #D6D6D6;
  font-weight: 500;
  font-size: .9rem;
  transition: background .15s ease, color .15s ease, transform .15s ease;
}
.sidebar__nav a:hover { background: rgba(255,255,255,.05); color: #fff; }
.sidebar__nav a.is-active {
  background: var(--crimson);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--red-bright);
}
.sidebar__nav .ico { width: 18px; text-align: center; font-size: 1rem; opacity: .9; }

.sidebar__user {
  padding-top: 1rem;
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
}
.sidebar__user-meta strong { display: block; font-size: .85rem; color: #fff; }
.sidebar__user-meta span { font-size: .7rem; color: var(--steel); text-transform: uppercase; letter-spacing: .12em; }

.main { padding: 2rem 2.25rem 3rem; max-width: 1400px; }

/* ====== Cards ====== */
.card {
  background: #fff;
  border: 1px solid var(--steel-200);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 1rem; }
.card__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.card__title { font-family: var(--font-serif); font-size: 1.4rem; margin: 0; }

/* ====== Stats grid (dashboard) ====== */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat {
  background: #fff;
  border: 1px solid var(--steel-200);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  position: relative;
  overflow: hidden;
}
.stat::before {
  content: ""; position: absolute; top: 0; left: 0; width: 3px; height: 100%;
  background: var(--crimson);
}
.stat.stat--blue::before { background: var(--globe-blue); }
.stat.stat--amber::before { background: var(--warn); }
.stat.stat--green::before { background: var(--ok); }
.stat__label { font-size: .72rem; text-transform: uppercase; letter-spacing: .14em; color: var(--steel); font-weight: 600; }
.stat__value { font-family: var(--font-serif); font-size: 2rem; line-height: 1.1; margin-top: .25rem; color: var(--ink); }
.stat__sub { font-size: .8rem; color: var(--steel); margin-top: .35rem; }

/* ====== Buttons ====== */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .55rem 1rem;
  background: var(--crimson);
  color: #fff;
  border: 1px solid var(--crimson);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans); font-weight: 600; font-size: .87rem;
  letter-spacing: .01em;
  cursor: pointer;
  transition: transform .1s ease, background .15s ease, box-shadow .15s ease;
  text-decoration: none;
}
.btn:hover { background: var(--crimson-700); color: #fff; box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(1px); }

.btn--ghost { background: transparent; color: var(--crimson); }
.btn--ghost:hover { background: rgba(166,25,46,.06); color: var(--crimson-700); }

.btn--dark { background: var(--ink); border-color: var(--ink); }
.btn--dark:hover { background: #000; }

.btn--outline { background: #fff; color: var(--ink); border-color: var(--steel-200); }
.btn--outline:hover { border-color: var(--ink); background: #fff; }

.btn--sm { padding: .35rem .7rem; font-size: .78rem; }

/* ====== Forms ====== */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem 1.25rem; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: .35rem; }
.field label {
  font-size: .73rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--ink-soft);
  font-weight: 700;
}
.field input, .field select, .field textarea {
  padding: .6rem .75rem;
  border: 1px solid var(--steel-200);
  border-radius: var(--radius-sm);
  background: #fff;
  font: inherit;
  color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--crimson);
  box-shadow: 0 0 0 3px rgba(166,25,46,.12);
}
.field textarea { resize: vertical; min-height: 70px; }
.fieldset {
  border: 1px solid var(--steel-200);
  border-radius: var(--radius);
  padding: 1rem 1.25rem 1.25rem;
  background: #fff;
}
.fieldset legend {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: .73rem;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--crimson);
  padding: 0 .5rem;
}

/* ====== Table ====== */
.table-wrap {
  background: #fff;
  border: 1px solid var(--steel-200);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
table.tbl { width: 100%; border-collapse: collapse; }
.tbl thead th {
  text-align: left;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--ink-soft);
  padding: .8rem 1rem;
  background: var(--steel-50);
  border-bottom: 1px solid var(--steel-200);
  font-weight: 700;
}
.tbl tbody td {
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--steel-200);
  vertical-align: middle;
}
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover { background: var(--steel-50); }
.tbl .num { font-family: var(--font-mono); font-size: .85rem; }

/* ====== Badges ====== */
.badge {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 999px;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.badge--gray  { background: #EEE; color: #555; }
.badge--blue  { background: #E4ECF7; color: var(--globe-blue); }
.badge--amber { background: #FCEFCF; color: var(--warn); }
.badge--green { background: #DDF1E5; color: var(--ok); }
.badge--red   { background: #FBE0E0; color: var(--danger); }

/* ====== Flash ====== */
.flash {
  padding: .85rem 1.1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  border-left: 3px solid;
  background: #fff;
  box-shadow: var(--shadow-sm);
}
.flash--success { border-color: var(--ok); }
.flash--error   { border-color: var(--danger); }
.flash--info    { border-color: var(--globe-blue); }

/* ====== Toolbar above lists ====== */
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; gap: 1rem; flex-wrap: wrap; }
.toolbar__search { flex: 1; max-width: 360px; }
.toolbar__search input { width: 100%; padding: .55rem .8rem; border: 1px solid var(--steel-200); border-radius: var(--radius-sm); font: inherit; }

/* ====== Login ====== */
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 20% 20%, rgba(166,25,46,.08), transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(31,78,140,.06), transparent 50%),
    var(--paper);
}
.login-card {
  width: 100%; max-width: 420px;
  background: #fff;
  border: 1px solid var(--steel-200);
  border-radius: 14px;
  padding: 2.25rem 2rem;
  box-shadow: var(--shadow-lg);
}
.login-card img { display: block; margin: 0 auto 1rem; width: 90px; height: 90px; object-fit: contain; }
.login-card h1 { font-family: var(--font-serif); font-size: 1.75rem; text-align: center; margin-bottom: .25rem; }
.login-card .sub { text-align: center; color: var(--steel); font-size: .85rem; margin-bottom: 1.5rem; }

/* ====== Print / Waybill Document ====== */
.waybill-doc {
  background: #fff;
  border: 1px solid var(--steel-200);
  border-radius: var(--radius);
  padding: 2.25rem 2.5rem;
  max-width: 880px;
  margin: 0 auto;
  color: var(--ink);
  font-family: var(--font-sans);
  position: relative;
}
.waybill-doc__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 2rem; padding-bottom: 1rem; border-bottom: 3px solid var(--crimson); }
.waybill-doc__brand img { height: 80px; }
.waybill-doc__brand .co { font-family: var(--font-serif); font-size: 1.5rem; color: var(--crimson); margin-top: .25rem; }
.waybill-doc__brand .tag { font-size: .75rem; color: var(--steel); letter-spacing: .14em; text-transform: uppercase; }
.waybill-doc__meta { text-align: right; }
.waybill-doc__meta .title { font-family: var(--font-serif); font-size: 1.7rem; color: var(--ink); }
.waybill-doc__meta .num { font-family: var(--font-mono); font-size: 1.15rem; color: var(--crimson); margin-top: .25rem; letter-spacing: .05em; }
.waybill-doc__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; margin-top: 1.25rem; }
.waybill-doc__block { border: 1px solid var(--steel-200); border-radius: var(--radius-sm); padding: 1rem 1.1rem; }
.waybill-doc__block h4 { font-family: var(--font-sans); font-weight: 700; font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: var(--crimson); margin-bottom: .55rem; }
.waybill-doc__block p { margin: .15rem 0; font-size: .9rem; }
.waybill-doc__block strong { color: var(--ink); }
.waybill-doc table { width: 100%; border-collapse: collapse; margin-top: 1.25rem; font-size: .88rem; }
.waybill-doc table th, .waybill-doc table td { padding: .55rem .65rem; border-bottom: 1px solid var(--steel-200); text-align: left; }
.waybill-doc table th { background: var(--steel-50); font-weight: 700; font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; }
.waybill-doc__totals { margin-top: 1.25rem; display: flex; justify-content: flex-end; }
.waybill-doc__totals table { width: 320px; margin: 0; }
.waybill-doc__signatures { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; margin-top: 2.25rem; }
.waybill-doc__sig { border-top: 1px solid var(--ink); padding-top: .5rem; font-size: .78rem; text-transform: uppercase; letter-spacing: .12em; color: var(--steel); }
.waybill-doc__footer { margin-top: 2.5rem; text-align: center; font-size: .75rem; color: var(--steel); border-top: 1px solid var(--steel-200); padding-top: 1rem; }

/* Watermark for draft / cancelled */
.waybill-doc.is-draft::after,
.waybill-doc.is-cancelled::after {
  content: attr(data-stamp);
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-family: var(--font-serif);
  font-size: 8rem;
  color: rgba(166,25,46,.06);
  letter-spacing: .2em;
  pointer-events: none;
  transform: rotate(-18deg);
}

.print-actions { display: flex; justify-content: center; gap: .75rem; margin: 1.25rem 0; }

@media print {
  body { background: #fff; }
  .app { display: block; }
  .sidebar, .print-actions, .flash, .main > h1 { display: none !important; }
  .main { padding: 0; max-width: none; }
  .waybill-doc { border: none; box-shadow: none; max-width: none; padding: 0; }
}

/* ====== Tracking timeline ====== */
.timeline { list-style: none; padding: 0; margin: 1rem 0 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 11px; top: 6px; bottom: 6px; width: 2px; background: var(--steel-200); }
.timeline li { position: relative; padding: 0 0 1rem 2rem; }
.timeline li::before { content: ""; position: absolute; left: 6px; top: 6px; width: 12px; height: 12px; border-radius: 50%; background: var(--crimson); box-shadow: 0 0 0 3px #fff; }
.timeline li .meta { font-size: .72rem; color: var(--steel); text-transform: uppercase; letter-spacing: .1em; }
.timeline li strong { display: block; margin: .15rem 0; }

/* ====== Responsive ====== */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; flex-direction: row; flex-wrap: wrap; gap: 1rem; }
  .sidebar__nav { flex-direction: row; flex-wrap: wrap; }
  .form-grid { grid-template-columns: 1fr; }
  .waybill-doc__grid { grid-template-columns: 1fr; }
  .waybill-doc__head { flex-direction: column; align-items: flex-start; }
  .waybill-doc__meta { text-align: left; }
  .main { padding: 1.25rem; }
}
