/* ALMAS Doku-Plattform · Apple-Lock-inspired with ALMAS Branding
   2026-04-29 Phase 1 */

:root {
  --almas-red: #d50000;
  --almas-red-hover: #b30000;
  --almas-bg: #fafafa;
  --almas-bg-alt: #f0f0f2;
  --almas-surface: #ffffff;
  --almas-surface-glass: rgba(255, 255, 255, 0.72);
  --almas-text: #0a0a0a;
  --almas-text-secondary: #6b7280;
  --almas-text-muted: #9ca3af;
  --almas-border: rgba(0, 0, 0, 0.08);
  --almas-border-strong: rgba(0, 0, 0, 0.16);
  --almas-shadow: 0 1px 2px rgba(0,0,0,0.05), 0 4px 12px rgba(0,0,0,0.04);
  --almas-shadow-lg: 0 8px 32px rgba(0,0,0,0.08);
  --radius: 14px;
  --radius-sm: 8px;
  --transition: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --font-system: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
                 "Segoe UI", "Helvetica Neue", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-system);
  font-size: 15px;
  line-height: 1.5;
  color: var(--almas-text);
  background: var(--almas-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.hidden { display: none !important; }
.text-secondary { color: var(--almas-text-secondary); }
.text-small { font-size: 13px; }
.text-link { color: var(--almas-red); text-decoration: none; font-weight: 500; }
.text-link:hover { text-decoration: underline; }

.view { min-height: 100vh; }

/* ═══════════════════════════════════════════════════════════
   BUTTONS
═══════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: inherit; font-size: 15px; font-weight: 500;
  cursor: pointer; user-select: none;
  transition: all var(--transition);
  background: transparent; color: var(--almas-text);
  text-decoration: none;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary {
  background: var(--almas-red); color: #fff;
  box-shadow: 0 1px 2px rgba(213,0,0,0.18);
}
.btn-primary:hover { background: var(--almas-red-hover); box-shadow: 0 4px 12px rgba(213,0,0,0.24); }
.btn-secondary { background: var(--almas-surface); color: var(--almas-text); border-color: var(--almas-border-strong); }
.btn-secondary:hover { background: var(--almas-bg-alt); }
.btn-ghost { background: transparent; color: var(--almas-text); }
.btn-ghost:hover { background: var(--almas-bg-alt); }
.btn-lg { padding: 14px 28px; font-size: 16px; border-radius: 12px; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-full { width: 100%; }

/* ═══════════════════════════════════════════════════════════
   LANDING PAGE
═══════════════════════════════════════════════════════════ */
.view-landing { background: linear-gradient(180deg, #fafafa 0%, #f0f0f2 100%); }

.lp-hero {
  display: grid; grid-template-columns: 1.1fr 0.9fr;
  gap: 64px; align-items: center;
  max-width: 1200px; margin: 0 auto;
  padding: 80px 32px 96px;
}
.lp-hero-content { max-width: 540px; }
.lp-logo img { height: 32px; opacity: 0.92; }
.lp-title {
  font-size: clamp(40px, 6vw, 72px);
  font-weight: 700; letter-spacing: -0.025em;
  margin: 28px 0 16px; line-height: 1.05;
  background: linear-gradient(135deg, #0a0a0a 0%, #d50000 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lp-subtitle { font-size: 19px; color: var(--almas-text-secondary); line-height: 1.45; margin: 0 0 36px; }
.lp-cta { display: flex; gap: 14px; flex-wrap: wrap; }

.lp-hero-visual {
  position: relative; aspect-ratio: 1.2/1;
  display: flex; align-items: center; justify-content: center;
}
.lp-glass-card {
  width: 100%; max-width: 380px;
  padding: 32px;
  background: var(--almas-surface-glass);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border: 1px solid var(--almas-border);
  border-radius: 24px;
  box-shadow: var(--almas-shadow-lg);
  transform: rotate(-2deg);
}
.lp-glass-line { height: 8px; border-radius: 4px; background: linear-gradient(90deg, #e5e5e7, #d4d4d8); margin-bottom: 14px; }
.lp-glass-line.short { width: 60%; }
.lp-glass-line.medium { width: 75%; }
.lp-glass-sig { margin-top: 28px; height: 60px; border-radius: 8px; background: linear-gradient(135deg, rgba(213,0,0,0.05), rgba(213,0,0,0.12)); border: 1px dashed rgba(213,0,0,0.3); position: relative; }
.lp-glass-sig::after {
  content: '✍️'; position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); font-size: 24px;
}

.lp-section { max-width: 1200px; margin: 0 auto; padding: 80px 32px; }
.lp-section-alt { background: #fff; max-width: none; }
.lp-section-alt > * { max-width: 1200px; margin-left: auto; margin-right: auto; }
.lp-section-title {
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 700; letter-spacing: -0.02em;
  text-align: center; margin: 0 0 56px;
}

.feature-grid, .step-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
}
.feature-card, .step-card {
  background: var(--almas-surface);
  border: 1px solid var(--almas-border);
  border-radius: var(--radius);
  padding: 32px 24px;
  transition: all var(--transition);
}
.feature-card:hover, .step-card:hover {
  transform: translateY(-4px); box-shadow: var(--almas-shadow-lg);
  border-color: var(--almas-border-strong);
}
.feature-icon { font-size: 36px; margin-bottom: 16px; }
.feature-card h3, .step-card h3 { margin: 0 0 8px; font-size: 19px; font-weight: 600; }
.feature-card p, .step-card p { margin: 0; color: var(--almas-text-secondary); font-size: 15px; line-height: 1.55; }

.step-number {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--almas-red) 0%, #ff3838 100%);
  color: #fff; font-weight: 700; font-size: 17px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 18px;
  box-shadow: 0 4px 12px rgba(213,0,0,0.24);
}

.lp-footer {
  background: #0a0a0a; color: rgba(255,255,255,0.7);
  padding: 32px 24px; font-size: 13px;
}
.lp-footer-content {
  max-width: 1200px; margin: 0 auto;
  display: flex; flex-wrap: wrap; gap: 16px 32px; justify-content: space-between;
}
.lp-footer a { color: #fff; text-decoration: none; }
.lp-footer a:hover { text-decoration: underline; }

/* ═══════════════════════════════════════════════════════════
   LOGIN
═══════════════════════════════════════════════════════════ */
.view-login {
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0a0a0a 0%, #1a1a1a 50%, #2a0808 100%);
  padding: 24px;
}
.login-card {
  background: var(--almas-surface-glass);
  backdrop-filter: blur(24px) saturate(1.6);
  -webkit-backdrop-filter: blur(24px) saturate(1.6);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 24px; padding: 48px 36px;
  width: 100%; max-width: 420px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.3);
  text-align: center;
}
.login-logo img { height: 36px; margin-bottom: 24px; }
.login-card h2 { margin: 0 0 8px; font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.login-card p { margin: 8px 0 24px; }
.login-card .btn { margin: 8px 0; }
.login-card .text-link { display: inline-block; margin-top: 24px; }

/* ═══════════════════════════════════════════════════════════
   APP (Sidebar + Content)
═══════════════════════════════════════════════════════════ */
.view-app {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #0a0a0a; color: #fff;
  display: flex; flex-direction: column;
  padding: 24px 16px;
  border-right: 1px solid rgba(255,255,255,0.05);
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 0 8px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sidebar-logo { height: 24px; filter: invert(1) brightness(1.5); }
.sidebar-title { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }

.sidebar-nav { flex: 1; padding: 16px 0; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px;
  color: rgba(255,255,255,0.7);
  text-decoration: none; font-size: 14px; font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.nav-item:hover { background: rgba(255,255,255,0.05); color: #fff; }
.nav-item.active { background: rgba(213,0,0,0.18); color: #fff; }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,0.06);
  padding-top: 16px;
}
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 8px; margin-bottom: 8px;
}
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--almas-red), #ff3838);
  color: #fff; font-weight: 600; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: rgba(255,255,255,0.5); text-transform: uppercase; letter-spacing: 0.05em; }
.sidebar-footer .btn-ghost { color: rgba(255,255,255,0.7); }
.sidebar-footer .btn-ghost:hover { background: rgba(255,255,255,0.06); color: #fff; }

.content { padding: 32px; max-width: 100%; overflow-x: auto; }
.tab-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.tab-header h1 { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }

.search-bar {
  display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 24px;
  background: var(--almas-surface); padding: 12px;
  border: 1px solid var(--almas-border); border-radius: var(--radius);
}
.search-bar input[type=search],
.search-bar select {
  padding: 8px 12px;
  border: 1px solid var(--almas-border);
  border-radius: var(--radius-sm);
  font-family: inherit; font-size: 14px;
  background: #fff;
}
.search-bar input[type=search] { flex: 1; min-width: 200px; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }

.empty-state {
  text-align: center; padding: 80px 24px;
  background: var(--almas-surface);
  border: 1px dashed var(--almas-border-strong);
  border-radius: var(--radius);
  grid-column: 1/-1;
}
.empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.6; }
.empty-state h3 { margin: 0 0 8px; font-size: 18px; font-weight: 600; }
.empty-state p { margin: 0 auto; max-width: 400px; }

/* ═══════════════════════════════════════════════════════════
   TOASTS
═══════════════════════════════════════════════════════════ */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 12px 16px; min-width: 240px; max-width: 360px;
  background: #fff; border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.16);
  font-size: 14px;
  animation: slideUp 0.2s ease-out;
}
.toast-success { border-left: 3px solid #16a34a; }
.toast-error { border-left: 3px solid var(--almas-red); }
.toast-info { border-left: 3px solid #3b82f6; }
@keyframes slideUp { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ═══════════════════════════════════════════════════════════
   ASSIGNMENT-CARDS, FIELDS, MODAL
═══════════════════════════════════════════════════════════ */
.assignment-card {
  background: var(--almas-surface); border: 1px solid var(--almas-border);
  border-radius: var(--radius); padding: 20px;
  cursor: pointer; transition: all var(--transition);
  display: flex; flex-direction: column; gap: 8px;
}
.assignment-card:hover { transform: translateY(-2px); box-shadow: var(--almas-shadow); border-color: var(--almas-border-strong); }
.assignment-status {
  align-self: flex-start;
  padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  background: var(--almas-bg-alt); color: var(--almas-text-secondary);
}
.assignment-status.status-open { background: #fef3c7; color: #92400e; }
.assignment-status.status-in_progress { background: #dbeafe; color: #1e40af; }
.assignment-status.status-completed { background: #d1fae5; color: #065f46; }
.assignment-status.status-unparsed { background: #fee2e2; color: #991b1b; }
.assignment-title { margin: 0; font-size: 17px; font-weight: 600; }
.assignment-meta { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--almas-text-secondary); }

.card-section {
  background: var(--almas-surface); border: 1px solid var(--almas-border);
  border-radius: var(--radius); padding: 24px; margin-bottom: 16px;
}
.card-section h2 { margin: 0 0 16px; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }

.kv-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}
.kv-grid > div { display: flex; flex-direction: column; gap: 2px; }
.kv-label { font-size: 12px; color: var(--almas-text-secondary); text-transform: uppercase; letter-spacing: 0.04em; }

.doc-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.doc-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px;
  background: var(--almas-bg-alt); border-radius: var(--radius-sm);
  cursor: pointer; transition: background var(--transition);
}
.doc-item:hover { background: #e5e5e7; }
.doc-status { padding: 2px 8px; border-radius: 6px; font-size: 11px; margin-left: 8px; }
.doc-status.status-draft { background: #fef3c7; color: #92400e; }
.doc-status.status-signed { background: #dbeafe; color: #1e40af; }
.doc-status.status-sent { background: #d1fae5; color: #065f46; }
.doc-create-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding-top: 8px; border-top: 1px solid var(--almas-border); }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--almas-text); }
.field input[type=text], .field input[type=date], .field input[type=time], .field input[type=number],
.field textarea, .field select {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--almas-border-strong); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 14px;
  background: var(--almas-surface);
  transition: all var(--transition);
}
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none; border-color: var(--almas-red);
  box-shadow: 0 0 0 3px rgba(213,0,0,0.12);
}
.field-inline { display: flex; align-items: center; gap: 8px; }
.field-inline input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--almas-red); }
.field-inline label { margin: 0; }
.required { color: var(--almas-red); margin-left: 4px; }

.radio-group { display: flex; flex-wrap: wrap; gap: 16px; }
.radio-option { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.radio-option input { accent-color: var(--almas-red); }

.sig-placeholder, .complex-placeholder {
  padding: 24px; text-align: center; color: var(--almas-text-muted);
  background: var(--almas-bg-alt); border: 1px dashed var(--almas-border-strong);
  border-radius: var(--radius-sm);
}

/* Sig pad + saved sig */
.sig-wrap { display: flex; flex-direction: column; gap: 8px; }
.sig-saved { display: flex; align-items: center; gap: 12px; padding: 8px 12px; background: var(--almas-bg-alt); border-radius: var(--radius-sm); }
.sig-img-saved { max-height: 60px; max-width: 240px; background: white; padding: 4px; border-radius: 4px; }
.sig-saved-meta { color: #16a34a; font-size: 13px; font-weight: 500; }
.sig-saved-mini { display: inline-flex; align-items: center; gap: 4px; padding: 4px 8px; background: #f0fdf4; border-radius: 6px; color: #16a34a; font-size: 12px; }
.sig-img-mini { max-height: 28px; max-width: 80px; }
#sigCanvas { border: 1px solid var(--almas-border-strong); border-radius: var(--radius-sm); background: #fff; width: 100%; max-width: 540px; cursor: crosshair; touch-action: none; }
.sig-actions { margin-top: 8px; }

/* Repeat list (alarm chain, material, person) */
.repeat-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.repeat-row { display: flex; gap: 8px; align-items: center; padding: 8px; background: var(--almas-bg-alt); border-radius: var(--radius-sm); }
.repeat-row > input, .repeat-row > select { flex: 1; min-width: 0; padding: 8px 10px; border: 1px solid var(--almas-border); border-radius: 6px; font-size: 13px; background: white; }
.repeat-row .row-num { width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; background: var(--almas-red); color: white; font-weight: 600; font-size: 12px; border-radius: 50%; flex-shrink: 0; }
.repeat-row-stack { flex-wrap: wrap; }

.form-section { margin-bottom: 16px; }
.form-section label { display: block; margin: 12px 0 6px; font-size: 13px; font-weight: 500; }
.form-section input, .form-section textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--almas-border-strong);
  border-radius: var(--radius-sm); font-family: inherit; font-size: 14px;
}
.form-row { display: flex; gap: 12px; }
.form-row > div { flex: 0 0 100px; }
.form-row > .grow { flex: 1; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  z-index: 200; display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal-card {
  background: var(--almas-surface); border-radius: var(--radius);
  padding: 28px; width: 100%; max-width: 480px;
  box-shadow: 0 32px 96px rgba(0,0,0,0.3);
}
.modal-card h2 { margin: 0 0 16px; font-size: 20px; font-weight: 600; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.customer-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.customer-card {
  background: var(--almas-surface); border: 1px solid var(--almas-border);
  border-radius: var(--radius); padding: 16px;
}
.customer-card h3 { margin: 0 0 4px; font-size: 15px; font-weight: 600; }

/* ═══════════════════════════════════════════════════════════
   MOBILE
═══════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  .lp-hero { grid-template-columns: 1fr; padding: 48px 20px 64px; gap: 40px; }
  .lp-hero-visual { order: -1; max-width: 320px; margin: 0 auto; }
  .view-app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: 0; right: 0; height: auto;
    flex-direction: row; padding: 12px 16px;
    border-right: none; border-bottom: 1px solid rgba(255,255,255,0.05);
    z-index: 50;
  }
  .sidebar-brand { padding: 0; border: none; }
  .sidebar-nav { flex-direction: row; padding: 0; gap: 4px; flex: 1; justify-content: center; overflow-x: auto; }
  .sidebar-nav .nav-item { padding: 8px 10px; }
  .nav-item span:not(.nav-icon) { display: none; }
  .sidebar-footer { border-top: none; padding-top: 0; padding-left: 12px; border-left: 1px solid rgba(255,255,255,0.06); }
  .sidebar-user { display: none; }
  .content { padding: 80px 16px 16px; }
}
